Community
Participate
Working Groups
Up until M6 given source text such as (@ is the cursor position) @xxxx it was possible to insert type if (yyyy != null) {@xxxx then new line to get if (yyyy != null) { xxxx } Now (in M6) and in eclipse-SDK-I20130402-0800-win32.zip we get if (yyyy != null) { }xxxx Super-irritating.
Reproducible in Build id: I20130326-0800. Steps to Reproduce: 1. Type: System.out.println(); 2. Go to the previous line and type: if(true) {| 3. Press Delete key on keyboard such that the text now is: if(true) {| System.out.println(); 4. Press Enter key and the text changes to: if(true) { }System.out.println();
Probably caused by fix for bug 395071.
Created attachment 229328 [details] Patch The bug was caused during the fix for bug 395071, by replacing the condition "if (hasNewToken && openingParen != -1)" with "if (openingParen != -1)". In the earlier condition, hasNewToken was false for this case and hence luckily the corresponding expression was not executed. But hasNewToken was producing incorrect result for other cases mentioned in that bug. This bug is present only in the case where we have a pair of '(' and ')' after the position where Enter is pressed. Then, openingParen contains the position of '(' from the pair present after the current position and in the next iteration causes the condition "if (openingParen != -1)" to be true. However, if we encounter a pair after the current position where Enter is pressed, openingParen should be reset to -1. Fixed this and also added a test case in JavaAutoIndentStrategyTest. Dani, please check.
Thanks Noopur! Committed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=98de7b54e9692cb1c0e42917238ed0376e594ac1