View | Details | Raw Unified | Return to bug 304705
Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-1 / +3 lines)
Lines 2692-2698 Link Here
2692
					if (newLineString == null) {
2692
					if (newLineString == null) {
2693
						StringBuffer newLineBuffer = new StringBuffer(this.lineSeparator);
2693
						StringBuffer newLineBuffer = new StringBuffer(this.lineSeparator);
2694
						this.column = 1;
2694
						this.column = 1;
2695
						printIndentationIfNecessary(newLineBuffer);
2695
						if (!this.formatter.preferences.never_indent_line_comments_on_first_column) {
2696
							printIndentationIfNecessary(newLineBuffer);
2697
						}
2696
					    newLineBuffer.append(LINE_COMMENT_PREFIX);
2698
					    newLineBuffer.append(LINE_COMMENT_PREFIX);
2697
						this.column += LINE_COMMENT_PREFIX_LENGTH;
2699
						this.column += LINE_COMMENT_PREFIX_LENGTH;
2698
						newLineString = newLineBuffer.toString();
2700
						newLineString = newLineBuffer.toString();
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+36 lines)
Lines 6203-6206 Link Here
6203
	    "}\n");
6203
	    "}\n");
6204
}
6204
}
6205
6205
6206
/**
6207
 * @bug 304705: [formatter] Unexpected indentation of wrapped line comments when 'Never indent line comment on first column' preference is checked
6208
 * @test Verify that wrapped line comments are also put at first column
6209
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304705"
6210
 */
6211
public void testBug304705() {
6212
	this.formatterPrefs.never_indent_line_comments_on_first_column = true;
6213
	String source = 
6214
		"public interface Example {\n" + 
6215
		"// This is a long comment    with	whitespace     that should be split in multiple line comments in case the line comment formatting is enabled\n" + 
6216
		"	int foo();\n" + 
6217
	    "}\n";
6218
	formatSource(source, 
6219
		"public interface Example {\n" + 
6220
		"// This is a long comment with whitespace that should be split in multiple line\n" + 
6221
		"// comments in case the line comment formatting is enabled\n" + 
6222
		"	int foo();\n" + 
6223
	    "}\n");
6224
}
6225
public void testBug304705b() {
6226
	this.formatterPrefs.never_indent_block_comments_on_first_column = true;
6227
	String source = 
6228
		"public interface Example {\n" + 
6229
		"/* This is a long comment    with	whitespace     that should be split in multiple line comments in case the line comment formatting is enabled */\n" + 
6230
		"	int foo();\n" + 
6231
	    "}\n";
6232
	formatSource(source, 
6233
		"public interface Example {\n" + 
6234
		"/*\n" + 
6235
		" * This is a long comment with whitespace that should be split in multiple line\n" + 
6236
		" * comments in case the line comment formatting is enabled\n" + 
6237
		" */\n" + 
6238
		"	int foo();\n" + 
6239
	    "}\n");
6240
}
6241
6206
}
6242
}

Return to bug 304705