microsoft/vscode

Add trigger type to CodeActionContext

Closed this issue · 2 comments

mjbvz commented

Part of #33555

Problems
Extensions currently do not know how a code actions request was triggered. Code actions may be requested automatically by vscode or when the user requests them

Proposal
Add a trigger type to CodeActionContext:

export interface CodeActionContext {
    readonly diagnostics: Diagnostic[];
    readonly trigger: 'auto' | 'manual';
}
  • auto: Code actions requested by VS Code automatically
  • manual: Code actions requested by user / command

Extensions could use this to determine which code actions they want to compute / show. For example, an extension may decide to only compute refactorings when a user requests them

// @jrieken

or example, an extension may decide to only compute refactorings when a user requests them

Not yet sure about that because one user might like that and another might not like that. I would solve the "noise" problem by richer code action information that allows for better sorting/filtering etc

I'd say we have something even better now