Community
Participate
Working Groups
Build ID: Build id: I20070222-0951 Steps To Reproduce: In a new Java project, default settings that is shipped with Eclipse (in particular "maximum line width" for line wrapping set to 80 chars use tabs (4 characters wide), type in this code: public class Start { public static void addHistTest() { // a comment that is longer than the maximum number of characters allowed on a line System.out.println("hi"); } } Hit CTRL-SHIFT-F once. The formatting changes to: public class Start { public static void addHistTest() { // a comment that is longer than the // maximum number of characters allowed // on a line System.out.println("hi"); } } Which doesn't quite line up (it is out by one character), but more importantly hitting CTRL-SHIFT-F changes the formatting to: public class Start { public static void addHistTest() { // a comment that is longer than the // maximum number of characters allowed // on a line System.out.println("hi"); } } Comment: Hitting CTRL-SHIFT-F should not change anything second time around, especially here where it makes the formatting worse. Also occurs in Version: 3.2.0 Build id: M20060629-1905
So the bugtracker has chopped everything at 80 chars or so, so what you see is not what the Editor displays. Never mind, following the actions will show that in the 2nd snippet of code, the comment start (//) are nearly lined up (out by 1 character) whereas in the 3rd snippet of code, they are way out.
(In reply to comment #0) > Which doesn't quite line up (it is out by one character), but more importantly > hitting CTRL-SHIFT-F changes the formatting to: > public class Start { > public static void addHistTest() { // a comment that is longer than the > // maximum number of characters allowed > // on a line > System.out.println("hi"); > } > } The formatter doesn't know that the three comments are "linked". What you mean is that continuous line comments should always be aligned ?
yes, comments that span multiple lines should be aligned. The formatter aligns the comments correctly when there is no code preceding the comment on that line, eg // comment1 // comment2 System.out.println("..."); but it gets it wrong when the comment spans multiple lines, where the first line of the comment also contains code, eg the result of formatting System.out.println("..."); // comment1 // comment2 becomes: System.out.println("..."); // comment1 // comment2 That kind of makes sense why it does this, but when the formatter breaks a comment into more than one line, it should consistently generate the same formatting, so that a second CTRL-SHIFT-F doesn't change the format again.
Ownership has changed for the formatter, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5. Please provide a patch if you definitely need the bug to be fixed in this version and I'll have a look at it... TIA
The formatter behaves correctly since 3.6M4 on the test case provided in comment 0. This is mainly due to the fix for bug 293300... *** This bug has been marked as a duplicate of bug 293300 ***
Verified for 3.6M5 using build I20100122-0800
Verified.