| Summary: | [formatter] format comments (differs between paste and save action) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Hajo Czub <Hajo> | ||||||||||
| Component: | Core | Assignee: | Frederic Fusier <frederic_fusier> | ||||||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | daniel_megert, jarthana, Olivier_Thomann | ||||||||||
| Version: | 3.6 | ||||||||||||
| Target Milestone: | 3.6.1 | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows XP | ||||||||||||
| See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=293300 https://bugs.eclipse.org/bugs/show_bug.cgi?id=305371 |
||||||||||||
| Whiteboard: | |||||||||||||
| Attachments: |
|
||||||||||||
Created attachment 169270 [details]
Formatter part for comments
Created attachment 169271 [details]
Settings of save action
(In reply to comment #0) >... > That's annoying. There is no workarround available There's one workaround, not perfect but if you add an empty lines between the commented line and the comment, this issue does not occur. For example: class X { public void testMethod() { // Comment 1 System.out.println("start"); // System.out.println("next"); // Comment 1 System.out.println("end"); } } The code is formatted properly, the line // Comment 1 is untouched. This was already broken using 3.6M6. I guess this regression was introduced while fixing some instabilities of the formatter: see bug 293300 which was fixed in 3.6M4. See also an already identified similar issue fixed in 3.6M7: bug 305371 Created attachment 169376 [details] Proposed patch It seems that the fix made for bug 305371 got a problem... I do not understand why the preference comment_format_line_comment_starting_on_first_column was used to see whether the comments indentations were similar or not! Anyway, removing this unexpected reference makes the formatter working properly. (In reply to comment #4) > Created an attachment (id=169376) [details] > Proposed patch > > It seems that the fix made for bug 305371 got a problem... I do not understand > why the preference comment_format_line_comment_starting_on_first_column was > used to see whether the comments indentations were similar or not! > > Anyway, removing this unexpected reference makes the formatter working > properly. Note that this fix shows me another really better workaround... Before unchecking the preference 'Enable line comment formatting', also uncheck the dependent reference 'Format line comments on first column'. Then the formatter will behave correctly :-) Daniel, Since the patch is so simple and it does fix the issue, I think this could be a good candidate for RC3. Formatting issues are painful as we learnt it the hard way for RC2. So +1 for RC3? +1 for RC3. Olivier, Srikanth, please review, thanks Srikanth will be off next two days, hence Jay, could you review the proposed patch? TIA +1 A small problem has been discovered with this fix running the massive tests. Differing to 3.6.1 to give more time to stabilize it. Created attachment 172574 [details]
New proposed patch
This new patch does not have any side effect while running the formatter massive tests.
(In reply to comment #12) > Created an attachment (id=172574) [details] > New proposed patch > Released for 3.6.1 in R3_6_maintenance stream. Released for 3.7M1 in HEAD stream. Verified for 3.6.1 RC2 using build M20100825-0800. |
Build Identifier: I20100429-1549 The result of the code format after the save action is not correct. Reproducible: Always Steps to Reproduce: Settings see appendings. 1. create a function like: public void testMethod() { // Comment 1 System.out.println("start"); System.out.println("next"); System.out.println("end"); } 2. save -> result: no change 3. mark the "next" line an comment this by using "shift + control + C" -> result: public void testMethod() { // Comment 1 System.out.println("start"); // System.out.println("next"); System.out.println("end"); } 4. save -> result: no change 5. copy the comment line after the commented "next" line -> result: public void testMethod() { // Comment 1 System.out.println("start"); // System.out.println("next"); // Comment 1 System.out.println("end"); } 6: save -> result: public void testMethod() { // Comment 1 System.out.println("start"); // System.out.println("next"); // Comment 1 System.out.println("end"); } That's annoying. There is no workarround available