Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 279359
Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-1 / +1 lines)
Lines 935-941 Link Here
935
			// preserve line breaks in wrapping if specified
935
			// preserve line breaks in wrapping if specified
936
			// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074
936
			// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074
937
			if (this.currentAlignment != null && this.memberAlignment != null && !this.formatter.preferences.join_wrapped_lines) {
937
			if (this.currentAlignment != null && this.memberAlignment != null && !this.formatter.preferences.join_wrapped_lines) {
938
				if (this.memberAlignment.depth() <= this.currentAlignment.depth()) {
938
				if (this.scanner.currentCharacter != '}' && this.memberAlignment.depth() <= this.currentAlignment.depth()) {
939
					int savedIndentation = this.indentationLevel;
939
					int savedIndentation = this.indentationLevel;
940
					StringBuffer buffer = new StringBuffer(getNewLine());
940
					StringBuffer buffer = new StringBuffer(getNewLine());
941
					this.indentationLevel = this.currentAlignment.breakIndentationLevel;
941
					this.indentationLevel = this.currentAlignment.breakIndentationLevel;
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+41 lines)
Lines 4495-4498 Link Here
4495
	);
4495
	);
4496
}
4496
}
4497
4497
4498
/**
4499
 * @bug 279359: [formatter] Formatter with 'never join lines' produces extra level of indent
4500
 * @test Ensure that no extra indentation is produced at the end of a body when
4501
 * 	'never join lines' preference is set.
4502
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=279359"
4503
 */
4504
public void testBug279359() throws JavaModelException {
4505
	this.formatterPrefs.join_wrapped_lines = false;
4506
	String source = 
4507
		"public class Formatter {\n" + 
4508
		"\n" + 
4509
		"        public static void main(String[] args) {\n" + 
4510
		"\n" + 
4511
		"                Executors.newCachedThreadPool().execute(new Runnable() {\n" + 
4512
		"\n" + 
4513
		"                        public void run() {\n" + 
4514
		"                                throw new UnsupportedOperationException(\"stub\");\n" + 
4515
		"                        }\n" + 
4516
		"\n" + 
4517
		"                });\n" + 
4518
		"\n" + 
4519
		"        }\n" + 
4520
		"}\n";
4521
	formatSource(source,
4522
		"public class Formatter {\n" + 
4523
		"\n" + 
4524
		"	public static void main(String[] args) {\n" + 
4525
		"\n" + 
4526
		"		Executors.newCachedThreadPool().execute(new Runnable() {\n" + 
4527
		"\n" + 
4528
		"			public void run() {\n" + 
4529
		"				throw new UnsupportedOperationException(\"stub\");\n" + 
4530
		"			}\n" + 
4531
		"\n" + 
4532
		"		});\n" + 
4533
		"\n" + 
4534
		"	}\n" + 
4535
		"}\n"
4536
	);
4537
}
4538
4498
}
4539
}

Return to bug 279359