Prevent unexpected rename cancellation#95739
Conversation
| return undefined; | ||
| } | ||
|
|
||
| this._cts = new EditorStateCancellationTokenSource(this.editor, CodeEditorStateFlag.Position | CodeEditorStateFlag.Value); |
There was a problem hiding this comment.
How about allowing to define a range in which position changes are OK? You could pass the rename-range into the ctor and test if the position is still within the range when selection or position changes happen
There was a problem hiding this comment.
I updated it. Since the token is used before the range is calculated, I also added a setter method. Could synchronization issues could arise in the future?
| let selection = this.editor.getSelection(); | ||
| let selectionStart = 0; | ||
| let selectionEnd = loc.text.length; | ||
| (this._cts as EditorStateCancellationTokenSource).range = loc.range; |
There was a problem hiding this comment.
This is not nice. The range property should not be mutable as that counters the idea of capturing a state to compare it against a future state. How about creating a new token? E.g. the token from line 146 is used to resolve the rename locations, then here dispose it and create new token with a (readonly) range
|
Thanks |
This PR fixes #92507
The problem was that the rename command was getting cancelled. When moving the cursor's position (but still staying within the rename target's range) the cancellation token thinks it should cancel because the cursor moved...
vscode/src/vs/editor/contrib/rename/rename.ts
Line 146 in d769191
... but the input field thinks we didn't cancel because the cursor is still within range.
vscode/src/vs/editor/contrib/rename/renameInputField.ts
Lines 188 to 193 in d769191
Therefore we can either update the input field's logic to be in line with the cancellation token rules, or we can temporarily stop using the cancellation token.
I implemented the latter.