Skip to content

Support to resolve code actions #106410

Closed
@jrieken

Description

@jrieken

Todays API for code actions wants all actions to be returned fully resolved, e.g the command or edit must be set. For some code action providers that's not easy and the usual "workaround" is to move the heavy lifting into the command (instead of using workspace edits). However, with commands it's harder to control the overall experience, like undo-stack or previewing changes.

The proposed change below adds a resolveCodeAction function to code action provider which the editor would call before applying a code action.

export interface CodeActionProvider<T extends CodeAction> {
  provideCodeActions(document: TextDocument, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | T)[]>;

  // NEW - allow to fill in things like edit or command
  resolveCodeAction(action: T, token: CancellationToken): ProviderResult<T>;
}

fyi @dbaeumer since this exists in LSP already

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions