mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 14:30:13 +00:00
Simplify showQuickPick
This commit is contained in:
parent
e8572c0221
commit
bd54e5f5cc
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue