Bug 49314 - comments formatted even if "Enable comment formatting" is disabled
Summary: comments formatted even if "Enable comment formatting" is disabled
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All Linux
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 172324 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-12-23 12:31 EST by Jon Nall CLA
Modified: 2007-04-27 07:35 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Nall CLA 2003-12-23 12:31:54 EST
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).
Comment 1 Tom Hofmann CLA 2003-12-23 13:02:22 EST
I assume you are using M6?
Comment 2 Jon Nall CLA 2003-12-23 13:40:42 EST
oh, sorry i didn't add that info.
Version: 3.0
Build id: 200312182000

which is 3.0-M6
Comment 3 Dani Megert CLA 2004-01-12 11:56:18 EST
Can be reproduced using I20040106
Comment 4 Tom Hofmann CLA 2004-01-14 05:40:55 EST
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
*/
Comment 5 Jon Nall CLA 2004-01-14 10:42:03 EST
yes, i've confirmed that it's in the core formatter.
Comment 6 Deven T. Corzine CLA 2004-01-27 12:06:13 EST
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.
Comment 7 Olivier Thomann CLA 2004-01-27 13:52:00 EST
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.
Comment 8 Deven T. Corzine CLA 2004-01-27 14:10:11 EST
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?
Comment 9 Olivier Thomann CLA 2004-04-30 16:07:31 EDT
Will reconsider post 3.0.
Comment 10 Olivier Thomann CLA 2007-03-18 13:27:50 EDT
Reopen
Comment 11 Olivier Thomann CLA 2007-04-23 09:54:05 EDT
If you expect your comment to be untouched when comment formatting is disabled, do you expect them to be indented?
Comment 12 Olivier Thomann CLA 2007-04-24 11:40:06 EDT
Released for 3.3M7.
Code released as part of bug 20793.
Regression test added in org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.test665()
Comment 13 Olivier Thomann CLA 2007-04-24 11:44:12 EDT
*** Bug 172324 has been marked as a duplicate of this bug. ***
Comment 14 Maxime Daniel CLA 2007-04-27 07:35:05 EDT
Verified for 3.3 M7 using build I20070427-0010.