diff --git a/packages/core/src/browser/quick-open/quick-pick-service-impl.ts b/packages/core/src/browser/quick-open/quick-pick-service-impl.ts index 38adbe068299e..6c75605287ebb 100644 --- a/packages/core/src/browser/quick-open/quick-pick-service-impl.ts +++ b/packages/core/src/browser/quick-open/quick-pick-service-impl.ts @@ -38,7 +38,9 @@ export class QuickPickServiceImpl implements QuickPickService { async show(elements: (string | QuickPickItem)[], options?: QuickPickOptions): Promise { return new Promise(resolve => { this.items = this.toItems(elements, resolve); - if (this.items.length === 1) { + // Set `runIfSingle` to the value passed through options, else defaults to true. + const runIfSingle: boolean = (options && options.runIfSingle !== undefined) ? options.runIfSingle : true; + if (runIfSingle && this.items.length === 1) { this.items[0].run(QuickOpenMode.OPEN); return; } diff --git a/packages/core/src/common/quick-pick-service.ts b/packages/core/src/common/quick-pick-service.ts index f3ee3725a96e8..95c8d93781c04 100644 --- a/packages/core/src/common/quick-pick-service.ts +++ b/packages/core/src/common/quick-pick-service.ts @@ -77,6 +77,12 @@ export interface QuickPickOptions { * The prefill value. */ value?: string; + + /** + * Determines if the quick pick with a single item should + * execute the item instead of displaying. The default is `true`. + */ + runIfSingle?: boolean; } export const quickPickServicePath = '/services/quickPick'; diff --git a/packages/plugin-ext/src/main/browser/quick-open-main.ts b/packages/plugin-ext/src/main/browser/quick-open-main.ts index 6887ce3860a90..6ed3d2268fe04 100644 --- a/packages/plugin-ext/src/main/browser/quick-open-main.ts +++ b/packages/plugin-ext/src/main/browser/quick-open-main.ts @@ -292,7 +292,8 @@ export class QuickOpenMainImpl implements QuickOpenMain, QuickOpenModel { title: options.title, totalSteps: options.totalSteps, ignoreFocusOut: options.ignoreFocusOut, - value: options.value + value: options.value, + runIfSingle: false, }); const disposableListeners = new DisposableCollection();