Skip to content

Commit

Permalink
Fix quick-pick initiated by the plugins not displaying with a single …
Browse files Browse the repository at this point in the history
…item

Fixes #6050

- fixes issue where `quick-pick` which were initiated by the plugins was
not displayed when it only contains a single item. The fix is to include
a new flag `runIfSingle` which is used to determine if the quick-pick
should display or execute the item.
- The default value for `runIfSingle` is set to `true`.
- The `plugin-ext` sets the `runIfSingle` to `false` so it always displays
the quick-pick regardless if an single item is present. This behavior is aligned
with previous versions of Theia and VSCode.

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Aug 28, 2019
1 parent fce7783 commit 292b538
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
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 default 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.
*/
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

0 comments on commit 292b538

Please sign in to comment.