diff --git a/src/vs/editor/contrib/codeAction/codeAction.ts b/src/vs/editor/contrib/codeAction/codeAction.ts index e6015b5d02b675355d7ef0b99e4c1f6669427d60..226893ae8490c2fdb38c1710133b508b07f4b380 100644 --- a/src/vs/editor/contrib/codeAction/codeAction.ts +++ b/src/vs/editor/contrib/codeAction/codeAction.ts @@ -83,7 +83,7 @@ function codeActionsComparator(a: CodeAction, b: CodeAction): number { } registerLanguageCommand('_executeCodeActionProvider', function (accessor, args) { - const { resource, range } = args; + const { resource, range, kind } = args; if (!(resource instanceof URI) || !Range.isIRange(range)) { throw illegalArgument(); } @@ -96,6 +96,6 @@ registerLanguageCommand('_executeCodeActionProvider', function (accessor, args) return getCodeActions( model, model.validateRange(range), - { type: 'manual', filter: { includeSourceActions: true } }, + { type: 'manual', filter: { includeSourceActions: true, kind: kind ? new CodeActionKind(kind) : undefined } }, CancellationToken.None); }); diff --git a/src/vs/workbench/api/node/extHostApiCommands.ts b/src/vs/workbench/api/node/extHostApiCommands.ts index 4d6070a34e79f7866d64d061145777eec1bff968..e487f6911c1739733da982e65373586d71cd5f6a 100644 --- a/src/vs/workbench/api/node/extHostApiCommands.ts +++ b/src/vs/workbench/api/node/extHostApiCommands.ts @@ -134,7 +134,8 @@ export class ExtHostApiCommands { description: 'Execute code action provider.', args: [ { name: 'uri', description: 'Uri of a text document', constraint: URI }, - { name: 'range', description: 'Range in a text document', constraint: types.Range } + { name: 'range', description: 'Range in a text document', constraint: types.Range }, + { name: 'kind', description: '(optional) Code action kind to return code actions for', }, ], returns: 'A promise that resolves to an array of Command-instances.' }); @@ -478,10 +479,11 @@ export class ExtHostApiCommands { }); } - private _executeCodeActionProvider(resource: URI, range: types.Range): Promise<(vscode.CodeAction | vscode.Command)[] | undefined> { + private _executeCodeActionProvider(resource: URI, range: types.Range, kind?: string): Promise<(vscode.CodeAction | vscode.Command)[] | undefined> { const args = { resource, - range: typeConverters.Range.from(range) + range: typeConverters.Range.from(range), + kind }; return this._commands.executeCommand('_executeCodeActionProvider', args) .then(tryMapWith(codeAction => {