Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java21
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java2
2 files changed, 23 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index 26bab5ad44..3bbf65b3d0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -13085,4 +13085,25 @@ public void testBug250656() {
" }\n" +
"}");
}
+/**
+ * https://bugs.eclipse.org/559006 - [formatter] Wrong indentation in region after wrapped line
+ */
+public void testBug559006() {
+ this.formatterPrefs.page_width = 50;
+ formatSource(
+ "class C {\n" +
+ " void f() {\n" +
+ " doSomething(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbb,\n" +
+ " + ccccccccccccccccccc);\n" +
+ "[# doSomethingElse();#]\n" +
+ " }\n" +
+ "}",
+ "class C {\n" +
+ " void f() {\n" +
+ " doSomething(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbb,\n" +
+ " + ccccccccccccccccccc);\n" +
+ " doSomethingElse();\n" +
+ " }\n" +
+ "}");
+}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
index 6c96bd92dc..0d74d61f99 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
@@ -818,6 +818,8 @@ public class LineBreaksPreparator extends ASTVisitor {
return false; // must be handling ast rewrite
if (previous != null && this.tm.countLineBreaksBetween(previous, token) == 0)
return false;
+ if (token.getLineBreaksBefore() == 0 && (previous == null || previous.getLineBreaksAfter() == 0))
+ return false;
int lineStart = token.originalStart;
char c;
while (lineStart > 0 && (c = this.tm.charAt(lineStart - 1)) != '\r' && c != '\n')

Back to the top