IDEA-195293 Strange behavior when join lines with "builder.append('...')"

This commit is contained in:
Tagir Valeev
2019-02-01 15:44:36 +07:00
parent 3971cd929b
commit 35990562bf
8 changed files with 27 additions and 5 deletions

View File

@@ -0,0 +1,7 @@
class Foo {
void test() {
StringBuilder sb = new StringBuilder();
<caret>sb.append("long-long-long-long-long-long-long-long-long-long-long-long-long-long-long");
sb.append("long-long-long-long-long-long-long-long-long-long-long-long-long-long-long");
}
}

View File

@@ -0,0 +1,7 @@
class Foo {
void test() {
StringBuilder sb = new StringBuilder();
sb.append("long-long-long-long-long-long-long-long-long-long-long-long-long-long-long")
.append("long-long-long-long-long-long-long-long-long-long-long-long-long-long-long");<caret>
}
}

View File

@@ -1,5 +1,5 @@
class Foo {
void test(int a, int b) {
if(a > 0 <caret>&& b < 0) System.out.println(a + b);
if(a > 0 &<caret>& b < 0) System.out.println(a + b);
}
}

View File

@@ -1,5 +1,5 @@
class Foo {
void test(int a, int b) {
if(a > 0 && a < 10 <caret>&& b > 0 && b < 10) System.out.println(a + b);
if(a > 0 && a < 10 &<caret>& b > 0 && b < 10) System.out.println(a + b);
}
}

View File

@@ -3,7 +3,7 @@ class Foo {
int a = 2;
int b = 2;
if (a == b && a > b) System.out.println();
<selection>if (a == b && a > b) System.out.println();</selection>
System.out.println();
}

View File

@@ -1,6 +1,6 @@
class Foo {
void test(int a, int b) {
if(a > 0 <caret>&& b < 0) {
if(a > 0 &<caret>& b < 0) {
System.out.println(a+b);
}
}

View File

@@ -43,6 +43,11 @@ public class JoinLinesTest extends LightCodeInsightTestCase {
public void testCallChain() { doTest(); }
public void testCallChain2() { doTest(); }
public void testCallChainLineBreak() {
CommonCodeStyleSettings settings = getJavaSettings();
settings.METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
doTest();
}
public void testCallChainWrong() { doTest(); }
public void testCallChainWrong2() { doTest(); }
public void testDeclarationAndCall() { doTest(); }

View File

@@ -187,12 +187,15 @@ public class JoinLinesHandler extends EditorActionHandler {
if (rc != CANNOT_JOIN) break;
}
}
docManager.doPostponedOperationsAndUnblockDocument(doc);
if (rc != CANNOT_JOIN) {
RangeMarker marker = doc.createRangeMarker(rc, rc);
docManager.doPostponedOperationsAndUnblockDocument(doc);
rc = marker.getStartOffset();
if (caretRestoreOffset.get() == CANNOT_JOIN) caretRestoreOffset.set(rc);
return;
}
docManager.doPostponedOperationsAndUnblockDocument(doc);
int replaceStart = start == offsets.lineEndOffset ? start : start + 1;
if (caretRestoreOffset.get() == CANNOT_JOIN) caretRestoreOffset.set(replaceStart);