Skip to content

A code action that has a command is never resolved, so its lazily computed edit is not applied #2191

Done

Description

@lagergren

Description

LSPLazyCodeActionIntentionAction.invoke resolves a code action only when it has neither an edit nor a command:

if (codeAction.getEdit() == null && codeAction.getCommand() == null
&& languageServer.getClientFeatures().getCodeActionFeature().isResolveCodeActionSupported(file)) {

A server that computes a code action's edit lazily, to a client that announces codeAction.resolveSupport.properties: ["edit"], may still return the action with a command to run after the edit. LSP4IJ then never sends codeAction/resolve for it: it executes the command alone, and the edit is never applied.

The specification has both apply: "If a code action provides an edit and a command, first the edit is executed and then the command." And codeAction/resolve is how a client fills in a lazily computed edit, whatever else the action has.

Steps to reproduce

  1. A language server answers textDocument/codeAction with an action that has data and a command, and no edit. LSP4IJ announces resolve support for edit.
  2. Choose that action in the editor.

Expected: LSP4IJ sends codeAction/resolve, applies the resolved edit, then executes the command.

Actual: no codeAction/resolve is sent; only the command is executed, and nothing is edited.

Suggested fix

Resolve an action that has no edit when the client supports resolving edit, whether or not it has a command, then apply the resolved action as apply does: its edit first, then its command.

Context

Found with the Ecstasy language server, whose safe delete code action carries a command that the client runs after the edit. Until this is fixed, the server sends the edit eagerly with any action that has a command.

Seen with LSP4IJ 0.30.1, and the condition is unchanged on main at 084bf75.

Activity

  1. added
    bug
    on Nov 24, 2026
  2. added this to the 0.30.2 milestone on Nov 24, 2026
  3. added a commit that references this issue on Nov 24, 2026
  4. added a commit that references this issue on Nov 24, 2026
    d592c89
  5. added 7 commits that reference this issue on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcodeAction

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions