Community
Participate
Working Groups
In the new code formatter, i have disabled "Enable comment formatting" however, when i format my code, the following: ===8<=====8<======8<=====8<====== /* Created on Dec 15, 2003 by jon.nall This is some more text and some more */ ===8<=====8<======8<=====8<====== gets formatted into: ===8<=====8<======8<=====8<====== /* Created on Dec 15, 2003 by jon.nall This is some more text and some more */ ===8<=====8<======8<=====8<====== note the space that gets added to each line. i expect my comments to go untouched if i've disabled "Enable comment formatting". when i save the formatting profile i see: <setting id="comment_format_comments" value="false"/> so it appears this option might not be respected. further, it doesn't seem to matter where in the file the comment is placed (i.e. it's not just a header comment only type of thing).
I assume you are using M6?
oh, sorry i didn't add that info. Version: 3.0 Build id: 200312182000 which is 3.0-M6
Can be reproduced using I20040106
I believe this is the core formatter that modifies the indent for multiline-comments (correct me if not). Of course, core cannot access the "format comments" jdt-ui preference, but perhaps you could either expose a preference for formatting comments and leave them alone if not? Or even introduce a preference to use c-style formatting: /** * c-style */
yes, i've confirmed that it's in the core formatter.
This is particularly bad when you choose to use C-style comments to comment out a block of code -- the new code formatter discards all the original indentation from the code and flush-aligns each line to a fixed indentation level. Because of this bug, I need to go back to using the old code formatter. How about only aligning the indentation of C-style comments if each line starts with a * character? That's probably the only time it's the right thing to do.
Does the C-style comment requires the first line to start with /**? In Java, this indicates a javadoc comment (vs a block comment). I can add an option to align starting stars in javadoc comments only. And leave the block comments untouched.
In this case, I'm talking about a block comment, not a Javadoc comment. However, I think it's perfectly reasonable (and desirable) for Javadoc AND block comments to have a leading * aligned with the opening /* of the comment, if EVERY line of the comment begins with a *. (If only some do, it might be a bullet list.) The comment I mentioned was a block comment containing code which had been commented out. All the indentation in this code was removed, making the code very difficult to read. Actually, looking again at the old formatter's behavior, it does reindent block comments, but it maintains all relative indentation within the comment. This is reasonable behavior, and handles lines of *'s and commented-out code equally well. Why is this not the behavior of the new formatter?
Will reconsider post 3.0.
Reopen
If you expect your comment to be untouched when comment formatting is disabled, do you expect them to be indented?
Released for 3.3M7. Code released as part of bug 20793. Regression test added in org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.test665()
*** Bug 172324 has been marked as a duplicate of this bug. ***
Verified for 3.3 M7 using build I20070427-0010.