| Summary: | Java code formatting incorrectly adds newline between "else" and line comment. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Garret Wilson <garret> | ||||
| Component: | Core | Assignee: | Mateusz Matela <mateusz.matela> | ||||
| Status: | VERIFIED DUPLICATE | QA Contact: | |||||
| Severity: | minor | ||||||
| Priority: | P3 | CC: | daniel_megert, jarthana, manoj.palat, mateusz.matela | ||||
| Version: | 4.3 | ||||||
| Target Milestone: | 4.8 M5 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | To be verified for 4.8 M5 | ||||||
| Attachments: |
|
||||||
This was first tested on Eclipse 4.2.2, and I have just confirmed that it does not work in Eclipse 4.3M7, either. Created attachment 230906 [details]
Eclipse Java formatting configuration exhibiting problem.
I've added a formatting configuration exported from Eclipse 4.3M7 exhibiting this problem.
Jesper, this is a minor one and you can look at it post 4.3 and Java 8. This problem no longer occurs after the formatter redesign. *** This bug has been marked as a duplicate of bug 303519 *** Verified for Eclipse Photon 4.8 M5 with Build id: I20180122-0800 |
I like aligned braces, but I also like to put a line comment on the "else" line, like this: if(expression) //if true { ... } else //if not true { ... } Regardless of my formatting settings, Eclipse formatting changes this to (note that the comment after the "else" has been moved to the next line): if(expression) //if true { ... } else //if not true { ... } I have tried all formatting settings combinations, including "insert newline before 'else' in an 'if' statement" and "preserve whitespace between code and line comments". Nothing works. I have raised the issue with a bounty on StackOverflow, but no one can make this work: http://stackoverflow.com/questions/15592984/ Some have indicated that some of the settings mentioned above worked on Galileo; this I cannot confirm. It seems this is a clear bug; I want my braces aligned, and I want my whitespace preserved between code and line comments. Eclipse is not complying.