### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v retrieving revision 1.198 diff -u -r1.198 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 3 Mar 2010 16:32:11 -0000 1.198 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 4 Mar 2010 17:33:05 -0000 @@ -2692,7 +2692,9 @@ if (newLineString == null) { StringBuffer newLineBuffer = new StringBuffer(this.lineSeparator); this.column = 1; - printIndentationIfNecessary(newLineBuffer); + if (!this.formatter.preferences.never_indent_line_comments_on_first_column) { + printIndentationIfNecessary(newLineBuffer); + } newLineBuffer.append(LINE_COMMENT_PREFIX); this.column += LINE_COMMENT_PREFIX_LENGTH; newLineString = newLineBuffer.toString(); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v retrieving revision 1.57 diff -u -r1.57 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 3 Mar 2010 11:17:35 -0000 1.57 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 4 Mar 2010 17:33:08 -0000 @@ -6203,4 +6203,40 @@ "}\n"); } +/** + * @bug 304705: [formatter] Unexpected indentation of wrapped line comments when 'Never indent line comment on first column' preference is checked + * @test Verify that wrapped line comments are also put at first column + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304705" + */ +public void testBug304705() { + this.formatterPrefs.never_indent_line_comments_on_first_column = true; + String source = + "public interface Example {\n" + + "// This is a long comment with whitespace that should be split in multiple line comments in case the line comment formatting is enabled\n" + + " int foo();\n" + + "}\n"; + formatSource(source, + "public interface Example {\n" + + "// This is a long comment with whitespace that should be split in multiple line\n" + + "// comments in case the line comment formatting is enabled\n" + + " int foo();\n" + + "}\n"); +} +public void testBug304705b() { + this.formatterPrefs.never_indent_block_comments_on_first_column = true; + String source = + "public interface Example {\n" + + "/* This is a long comment with whitespace that should be split in multiple line comments in case the line comment formatting is enabled */\n" + + " int foo();\n" + + "}\n"; + formatSource(source, + "public interface Example {\n" + + "/*\n" + + " * This is a long comment with whitespace that should be split in multiple line\n" + + " * comments in case the line comment formatting is enabled\n" + + " */\n" + + " int foo();\n" + + "}\n"); +} + }