Community
Participate
Working Groups
I20071101-2000. Test Case: 1. create a CU like this --- %< --- public class Test { int i= 1; } --- %< --- 2. select the second line from left to right 3. format (Ctrl+Shift+F) ==> The indentation is not corrected and trailing space is not removed. Since we call API that gives JDT Core the full CU plus the correct region I'd expect this line to end up as if the I had formatted the whole CU. This bug causes special grief when only formatting the changed lines when saving: as we pass the changed lines as an array of regions to the formatter using the new formatter API.
Do you include whitespaces in the selection? Since you pushed to get the API in for M3, you are more than welcome to propose a patch for this one.
>Do you include whitespaces in the selection? The full line excluding whitespace >Since you pushed to get the API in for M3, you are more than welcome to propose >a patch for this one. Please... This has *nothing* to do with the new API. Same bug in R3.3 with the old API.
Glad to hear that it has nothing to do with the new API. Not obvious with the initial comment.
Sorry about that. Thought it was clear because formatting a single selection is nothing new and you can't have more than one selection in the editor ;-)
Formats ok without selection
Eric, please fix for 3.4M4 (ask Olivier for help if fix is not obvious).
Created attachment 82969 [details] [proposed patch + test cases] on top v824 - all jdt.core tests OK all jdt.ui and jdt.text tests OK
(In reply to comment #7) Olivier: may you please review proposed patch - thanks
Created attachment 82986 [details] New proposal New proposal based on the previous patch. Small changes to minimize the number of method invocations. Eric, please review. If ok, then you can release.
Patch released for 3.4M4 in HEAD.
Benno please, check whether we can bail out of our workaround code now.
(In reply to comment #11) > Benno please, check whether we can bail out of our workaround code now. I still have a failing test case when I remove the workaround. Steps to reproduce: Given: package test1; public class Test { int i = 1; } 1. Select line with field decl 2. Format Is: the spaces after the field decl are not removed Should: be removed The strange thing here is, if I do the exact same thing but with: Given: public class Test { int i = 1; } it works as expected (hint the missing package decl)
reopen
(In reply to comment #13) investigating
Created attachment 83270 [details] [proposed patch + new test case] on top v824 - all jdt.core tests OK improved patch - all jdt.ui and jdt.text OK. Olivier, please review - thanks
(In reply to comment #15) > Created an attachment (id=83270) [details] > [proposed patch + new test case] on top v824 - all jdt.core tests OK > > improved patch - all jdt.ui and jdt.text OK. > Olivier, please review - thanks > I have two problems with this. First it still does not work if: Given: package test1; public class Test { int i = 1; } 1. File>Convert Line Delimiters To>Unix 2. Select the line with the field decl 3. Format Second, you now change the offset and length of regions in the array of Region passed to the formatter, this is unexpected, you must not modify objects passed in as parameters to a method unless this is specified. Modifying this array is a problem for me because I would need to make a copy before I pass it to the formatter, each time, on save.
Created attachment 83555 [details] [proposed patch + test cases] on top v825 all jdt.core, ui and text OK Olivier, may you please review - thanks
Introduced bug 210922
Verified for 3.4M4 using build I20071210-1800.
Also introduced bug 222182