View | Details | Raw Unified | Return to bug 282988 | Differences between
and this patch

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-2 / +4 lines)
Lines 2457-2463 Link Here
2457
							// delete consumed white spaces
2457
							// delete consumed white spaces
2458
							hasWhitespaces = true;
2458
							hasWhitespaces = true;
2459
							currentTokenStartPosition = this.scanner.currentPosition;
2459
							currentTokenStartPosition = this.scanner.currentPosition;
2460
							addDeleteEdit(tokenStartPosition, whitespacesEndPosition);
2460
							if (this.formatter.preferences.comment_format_line_comment) {
2461
								addDeleteEdit(tokenStartPosition, whitespacesEndPosition);
2462
							}
2461
						} else {
2463
						} else {
2462
							if (lines == 0) {
2464
							if (lines == 0) {
2463
								hasWhitespaces = true;
2465
								hasWhitespaces = true;
Lines 2731-2737 Link Here
2731
		this.lastLineComment.indentation = commentIndentationLevel;
2733
		this.lastLineComment.indentation = commentIndentationLevel;
2732
		
2734
		
2733
		// Add pending space if necessary
2735
		// Add pending space if necessary
2734
    	if (this.pendingSpace) {
2736
    	if (this.formatter.preferences.comment_format_line_comment && this.pendingSpace) {
2735
    		addInsertEdit(currentTokenStartPosition, " "); //$NON-NLS-1$
2737
    		addInsertEdit(currentTokenStartPosition, " "); //$NON-NLS-1$
2736
    	}
2738
    	}
2737
    	this.needSpace = false;
2739
    	this.needSpace = false;
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+32 lines)
Lines 7628-7631 Link Here
7628
		"}\n"
7628
		"}\n"
7629
	);
7629
	);
7630
}
7630
}
7631
7632
/**
7633
 * @bug 282988: [formatter] Option to align single-line comments in a column
7634
 * @test Ensure that with line comment formatting turned off comment alignment doesn't change 
7635
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988"
7636
 */
7637
public void testBug282988() throws Exception {
7638
	this.formatterPrefs.comment_format_line_comment = false;
7639
	String source =
7640
		"package test;\n" +
7641
		"\n" +
7642
		"public class FormatterError {\n" +
7643
		"	public void storeSomething(java.nio.ByteBuffer buffer) throws Exception {\n" +
7644
		"		buffer.clear();\n" +
7645
		"		buffer.putLong(0);     // backlink to previous version of this object\n" +
7646
		"		buffer.putInt(1);      // version identifier\n" +
7647
		"		buffer.flip();         // prepare to write\n" +
7648
		"	}\n" +
7649
		"}\n";
7650
	formatSource(source,
7651
		"package test;\n" +
7652
		"\n" +
7653
		"public class FormatterError {\n" +
7654
		"	public void storeSomething(java.nio.ByteBuffer buffer) throws Exception {\n" +
7655
		"		buffer.clear();\n" +
7656
		"		buffer.putLong(0);     // backlink to previous version of this object\n" +
7657
		"		buffer.putInt(1);      // version identifier\n" +
7658
		"		buffer.flip();         // prepare to write\n" +
7659
		"	}\n" +
7660
		"}\n"
7661
    );
7662
}
7631
}
7663
}

Return to bug 282988