Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quick-pick initiated by the plugins not displaying with 1 item #6059

Merged
merged 1 commit into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export class QuickPickServiceImpl implements QuickPickService {
async show(elements: (string | QuickPickItem<Object>)[], options?: QuickPickOptions): Promise<Object | undefined> {
return new Promise<Object | undefined>(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;
}
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/common/quick-pick-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/main/browser/quick-open-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down