Community
Participate
Working Groups
Consider the following lines: private static final String CONTENT = "test.ObjectB {\n" + " multiEle = { name=\"Foo\" }\n" + " multiEle = :x { name=\"Bar\" }\n" + " singleEle = x;\n" + "}"; The file is saved. Now: 1. Reformat the whole document. 2. The indentation of the second line is corrected and the second line is marked as being edited. 3. Now, save again with "Format edited line" turned on. The indentation of the second line incorrectly is changed back because only the second line is considered since the first line has not been changed. This problem makes the "Format edited line" option rather unusable.
Looks like a selection format problem. 1. paste this code into Package Explorer: public class Bug239447 { private static final String CONTENT = "test.ObjectB {\n" + " multiEle = { name=\"Foo\" }\n" + " multiEle = :x { name=\"Bar\" }\n" + " singleEle = x;\n" + "}"; } 2. Format 3. Save 4. delete the leading whitespace of line 3 5. select line 3 (from start to end) 6. format ==> OK: line gets correctly indented as it was after save 7. now add some whitespace to line 3 (before the '+') 8. select line 3 (from start to end) 9. format ==> BUG: line not correctly indented
I can reproduce the problem described in comment 1 which is a consequence of bug 234583. However, I cannot reproduce the initial issue described in comment 0: can you attach the formatter profile used for this test case? Using the default Eclipse built-in profile, here's the output I get: public class Test { >> private static final String CONTENT = "test.ObjectB {\n" >> >> >> "multiEle = { name=\"Foo\" }\n" >> >> >> + " multiEle = :x { name=\"Bar\" }\n" + " singleEle = x;\n" >> >> >> + "}"; } (I replaced the tabulations with '>> ' to show the used indentation character) Reformatting this output does not change any lines, hence the problem does not occur.
Created attachment 106712 [details] Formatter used for comment #0 I attached the formatter.
(In reply to comment #3) > Created an attachment (id=106712) [details] > Formatter used for comment #0 > > I attached the formatter. > I still cannot reproduce even with your profile... Based on your comment 0, here's the test case I'm starting from to run your steps: public class Test { ........private static final String CONTENT = "test.ObjectB {\n" ........+ " multiEle = :x { name=\"Bar\" }\n"; } I've removed some strings to make it readable with bugzilla and also shown lines leading spaces replacing them by '.' Step 1: format the whole unit ------ Using your profile but reducing the line wrapping to 80 to have the same line split than with your initial snippet, I get the following output: public class Test { >> private static final String CONTENT = "test.ObjectB {\n" >> >> >> + " multiEle = :x { name=\"Bar\" }\n"; } Step 2: As you can see, both lines 2 and 3 are modified while formatting ------ Step 3: Save with "Format edited line" turned on ------ I still get the same output after this save action as the two lines were correctly formatted after step 1: public class Test { >> private static final String CONTENT = "test.ObjectB {\n" >> >> >> + " multiEle = :x { name=\"Bar\" }\n"; }
Did you try to just modify the second line and then format the edited lines only?
(In reply to comment #5) > Did you try to just modify the second line and then format the edited lines > only? > Yes, see my answer in comment 2: > I can reproduce the problem described in comment 1 which is a consequence of > bug 234583. > But the scenario described in comment 1 was different than yours... And as you didn't say that comment 1 scenario should be used instead or that your scenario was missing one step: modify the line 2, I desperately tried to reproduce yours :-( So, the conclusion is that your issue is also a consequence of bug 234583 => set it as duplicate because fix for bug 234583 will fix this one... *** This bug has been marked as a duplicate of bug 234583 ***
Verified for 3.5M2 using I20080914-2000