Skip to content

Commit

Permalink
Return undefined if empty array passed into quick pick service
Browse files Browse the repository at this point in the history
Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>
  • Loading branch information
vzhukovs committed Jan 15, 2020
1 parent 183ba3e commit 7b275d2
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ 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 === 0) {
resolve(undefined);
return;
}
// 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) {
Expand Down

0 comments on commit 7b275d2

Please sign in to comment.