Skip to content

Commit

Permalink
small refine of util method.
Browse files Browse the repository at this point in the history
  • Loading branch information
RodgeFu committed Jan 10, 2025
1 parent a8a2f30 commit 90878bc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/typespec-vscode/src/ui-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import vscode, {
CancellationToken,
OpenDialogOptions,
Progress,
QuickPick,
QuickPickItem,
QuickPickItemButtonEvent,
QuickPickOptions,
Expand Down Expand Up @@ -50,7 +51,7 @@ export async function confirm<
ignoreFocusOut: true,
};
const items = [yes, no];
const selected = await showQuickPickWithButtons(items, options, (event) => {
const selected = await showQuickPickWithButtons(items, options, (_quickpick, event) => {
if (event.item === yes && yes.externalLink) {
vscode.env.openExternal(vscode.Uri.parse(yes.externalLink));
} else if (event.item === no && no.externalLink) {
Expand Down Expand Up @@ -254,7 +255,7 @@ export async function tryExecuteWithUi<
export async function showQuickPickWithButtons<T extends QuickPickItem>(
items: T[],
options: QuickPickOptions,
onItemButtonTriggered: (item: QuickPickItemButtonEvent<T>) => void,
onItemButtonTriggered: (quickpick: QuickPick<T>, item: QuickPickItemButtonEvent<T>) => void,
) {
const quickPickup = vscode.window.createQuickPick<T>();
quickPickup.items = items;
Expand All @@ -265,8 +266,7 @@ export async function showQuickPickWithButtons<T extends QuickPickItem>(
if (options.matchOnDescription) quickPickup.matchOnDescription = options.matchOnDescription;
if (options.matchOnDetail) quickPickup.matchOnDetail = options.matchOnDetail;
quickPickup.onDidTriggerItemButton((event) => {
onItemButtonTriggered(event);
quickPickup.hide();
onItemButtonTriggered(quickPickup, event);
});
const selectionPromise = new Promise<T[] | undefined>((resolve) => {
quickPickup.onDidAccept(() => {
Expand Down

0 comments on commit 90878bc

Please sign in to comment.