Community
Participate
Working Groups
I20101028-1441 Steps - Select longName - Ctrl+1 > Rename in file - Rename the variable to 'name', press enter to exit linked mode - 'n' in 'name' is selected and the caret is also placed after 'n' Correct behavior: 'name' is selected and caret placed after 'name' package test1; public class E { private void foo() { int longName = 10; //select on this line longName++; longName--; --longName; ++longName; } } This works correctly with Ctrl+1 > Rename in Workspace. (Though if you notice carefully, for a split second it shows the same selection as Rename in File before it corrects itself.)
Like that since day one. Either a general Linked Mode bug or a bug in LinkedNamesAssistProposal. Markus, can you take a look?
I see the same problem with 'Extract to local variable', 'Extract to constant', 'Extract to method' quick assists.
Simpler example for debugging (note that the original position of the caret is important): - have class: class ClassToRename {} - copy "bla" to clipboard - put caret before "ClassToRename" - Ctrl+2, R - select "ClassTo" - paste Now what happens is this: - DefaultPositionUpdater.update(DocumentEvent) gets an update event that replaces "ClassTo" with "bla" (good) - The second position to update is a LinkedPosition; this is the exit position that has been set earlier in LinkedModeUI#setExitPosition(). Its length is 0. - When DefaultPositionUpdater#adaptToRemove() is called for that position, the LinkedPosition's length is wrongly set to -1, but this get corrected at the end of the method. - In DefaultPositionUpdater#adaptToInsert(), the bug happens on line 117, where fPosition.length += fReplaceLength; wrongly increases the length of the exit position.
Created attachment 182928 [details] fix and tests This is a long standing bug in the DefaultPositionUpdater. Will release after next I-build, since I'll not be around till Wednesday, and since this needs a full week of selfhost-testing (to find possible collateral damage in clients that relied on the wrong behavior).
Fixed in HEAD.
Created attachment 183420 [details] fix and tests 2 The original fix was not fully consistent and produced test failures. Fixed in HEAD with this patch.