You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A workspace edit applies to a target that was typed into and undone while its request was pending #2284
WorkspaceEditSnapshot checks a target that the language server had open at capture by its document's modification stamp (WorkspaceEditSnapshot.java:229-231):
An undo puts back the document's earlier modification stamp (EditorChangeAction.undo, seen in the 2024.2 bytecode). So if the user types into a target while a rename, a codeAction/resolve or an incoming workspace/applyEdit is pending, and then undoes it, the stamp matches again and the edit is applied. Meanwhile the server was sent the typed text (didChange) and then the original text, and it may have computed its edit against the typed text.
When it can matter
All of these must hold, so it is rare:
the edit carries no version (a TextDocumentEdit with a version above 0 is still checked against the current version, which the two didChange have moved on);
the user types into the target, then undoes it, while the reply is pending;
the server computes its reply against the intermediate text.
The edit would then apply offsets of the typed text to the original text.
Suggested fix
Also record the synchronizer's version at capture, and require it to be unchanged. Every didChange raises it, an undo included. Alternatively, use the change sequence that #2283 adds (WorkspaceEditSnapshot.TextChanges), which already counts an undone change as a change.
Activity
fix: a workspace edit is refused for a target that was changed and un…