Skip to content

Commit

Permalink
Fixes microsoft#78098: Return isPreferred from vscode.executeCodeActi…
Browse files Browse the repository at this point in the history
…onProvider
  • Loading branch information
ypresto committed Aug 8, 2019
1 parent bb27a11 commit 46c702b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHostApiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ export class ExtHostApiCommands {
if (codeAction.command) {
ret.command = this._commands.converter.fromInternal(codeAction.command);
}
ret.isPreferred = codeAction.isPreferred;
return ret;
}
}));
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,8 @@ export class CodeAction {

kind?: CodeActionKind;

isPreferred?: boolean;

constructor(title: string, kind?: CodeActionKind) {
this.title = title;
this.kind = kind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,33 @@ suite('ExtHostLanguageFeatureCommands', function () {
});
});

test('vscode.executeCodeActionProvider results seem to be missing their `isPreferred` property #78098', function () {
disposables.push(extHost.registerCodeActionProvider(nullExtensionDescription, defaultSelector, {
provideCodeActions(document, rangeOrSelection): vscode.CodeAction[] {
return [{
command: {
arguments: [document, rangeOrSelection],
command: 'command',
title: 'command_title',
},
kind: types.CodeActionKind.Empty.append('foo'),
title: 'title',
isPreferred: true
}];
}
}));

const selection = new types.Selection(0, 0, 1, 1);

return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, selection).then(value => {
assert.equal(value.length, 1);
const [first] = value;
assert.equal(first.isPreferred, true);
});
});
});

// --- code lens

test('CodeLens, back and forth', function () {
Expand Down

0 comments on commit 46c702b

Please sign in to comment.