Community
Participate
Working Groups
Created attachment 97436 [details] JUnit test case to reproduce the problem This issue has been discovered while activating new comment formatter (see bug 102780 and bug 227043) on clean-up action but in fact already exists in 3.3. The new line is not inserted while formatting the compilation unit through the menu item or using Ctrl-Shift-F, but only using the CodeFormatter.format(int, String, int, int, int, String ) method with kind = K_COMPILATION_UNIT with an offset and a length. Attached the JUnit test case to reproduce the problem...
The problem is in Scribe.isValidEdit(int) method. When the position is not in the covered region, then the edit is wrongly modified at line 943: if (i - editOffset != editReplacementLength && i != editOffset + editLength - 1) { edit.offset = starting.getOffset(); edit.length = 0; edit.replacement = edit.replacement.substring(i - editOffset); return true; } This if block definitely looks suspiciousn, especially start position and length... Comment it fixes the problem but I'll see if I can write a smarter fix.
The is a side effect of bug 49817. The fix of that bug does not seem related to the original issue, so we need to investigate whether that fix can be removed or not... Olivier, what is your mind about this?
Close as worksforme because I cannot reproduce using 3.5M2. My assumption is that the problem vanished when bug 234583 has been fixed. Edits are now split hence the condition of the offending if should not be true anymore...
The test case from comment 0 still fails for me but for another reason (see bug 252556). However a new line is not inserted, so marking as verified for 3.5M3 using I20081027-1800.