Simplify showQuickPick

This commit is contained in:
Matt Bierner 2020-09-18 16:51:59 -07:00
parent e8572c0221
commit bd54e5f5cc

View file

@ -368,29 +368,19 @@ class ApplyCompletionCodeActionCommand implements Command {
return applyCodeAction(this.client, codeActions[0], nulToken);
}
interface MyQuickPickItem extends vscode.QuickPickItem {
index: number;
}
const selection = await vscode.window.showQuickPick<MyQuickPickItem>(
codeActions.map((action, i): MyQuickPickItem => ({
const selection = await vscode.window.showQuickPick(
codeActions.map(action => ({
label: action.description,
description: '',
index: i
action,
})), {
placeHolder: localize('selectCodeAction', 'Select code action to apply')
}
);
});
if (!selection) {
return false;
if (selection) {
return applyCodeAction(this.client, selection.action, nulToken);
}
const action = codeActions[selection.index];
if (!action) {
return false;
}
return applyCodeAction(this.client, action, nulToken);
return false;
}
}