Repository navigation
fix: resolve a code action that has a command but no edit, so that its lazily computed edit is applied before the command - #2193
Merged
lagergren merged 1 commit intoNov 24, 2026
Conversation
…s lazily computed edit is applied before the command LSPLazyCodeActionIntentionAction resolved a code action only when it had neither an edit nor a command. A language server that computes a code action's edit lazily, as LSP4IJ's resolveSupport for "edit" allows, may still give the action a command to execute after the edit, as the Ecstasy language server's safe delete does. LSP4IJ then never sent codeAction/resolve: it executed the command alone, and nothing was edited. A code action without an edit is now resolved whenever the language server supports codeAction/resolve, whatever else it has, as VS Code does. The resolved action is applied as before: its edit first, in a command of its own that Undo reverts, then its command, as LSP says. Fixes redhat-developer#2191
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2193 +/- ##
==========================================
+ Coverage 54.23% 54.29% +0.06%
==========================================
Files 832 832
Lines 35334 35334
Branches 7286 5535 -1751
==========================================
+ Hits 19163 19186 +23
+ Misses 13348 13327 -21
+ Partials 2823 2821 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
@coderabbitai review |
Action not completed
|
Collaborator
Author
|
@coderabbitai review |
Action performed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2191
What
LSPLazyCodeActionIntentionAction.invokeresolved a code action only when it had neither aneditnor acommand. LSP4IJ announcescodeAction.resolveSupport.properties: ["edit"], so a language server may compute a code action's edit lazily and still give the action acommandto execute after the edit. The Ecstasy language server's safe delete does this. LSP4IJ then never sentcodeAction/resolve: it executed the command alone, and nothing was edited.Change
A code action without an
editis now resolved whenever the language server supportscodeAction/resolve, whether or not it has acommand. VS Code does the same: it resolves any action without an edit when its provider can resolve. The resolved action is then applied as before:LSP says "If a code action provides an edit and a command, first the edit is executed and then the command."
A code action that has an edit, or a language server without
resolveProvider, is applied as before.Tests
ResolvedCodeActionTest.testACodeActionWithACommandIsResolvedForItsEditWhichIsAppliedBeforeTheCommand: a code action withdataand acommand, and noedit, is resolved to an edit. Invoking it applies the edit and then executes the command throughworkspace/executeCommand.worldinstead ofhello world, as nocodeAction/resolveis sent.features.codeAction.*andcommands.*tests pass on IC 2024.2, 2025.3 and IU 2026.3: 43 each, with 0 failures or skipped.Behaviour change
commandand noedit, from a language server that resolves code actions, executes its command alone, and its lazily computed edit is never asked for