Skip to content

Commit

Permalink
window.showQuickPick is not closed when promise is rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Nov 26, 2015
1 parent 4a85ac5 commit 5dbc95b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/vs/workbench/api/browser/pluginHostQuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export class PluginHostQuickOpen {
return items[handle];
}
});
}, (err) => {
this._proxy._setError(err);

return TPromise.wrapError(err);
});
}

Expand All @@ -80,6 +84,7 @@ export class MainThreadQuickOpen {

private _quickOpenService: IQuickOpenService;
private _doSetItems: (items: MyQuickPickItems[]) => any;
private _doSetError: (error: Error) => any;
private _contents: TPromise<MyQuickPickItems[]>;
private _token = 0;

Expand All @@ -97,6 +102,12 @@ export class MainThreadQuickOpen {
c(items);
}
};

this._doSetError = (error) => {
if (myToken === this._token) {
e(error);
}
};
});

return this._quickOpenService.pick(this._contents, options).then(item => {
Expand All @@ -113,6 +124,13 @@ export class MainThreadQuickOpen {
}
}

_setError(error: Error): Thenable<any> {
if (this._doSetError) {
this._doSetError(error);
return;
}
}

_input(options?: InputBoxOptions): Thenable<string> {
return this._quickOpenService.input(options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
onOk: () => { /* ignore, handle later */ },
onCancel: () => { /* ignore, handle later */ },
onType: (value: string) => { /* ignore, handle later */ },
onShow: () => this.emitQuickOpenVisibilityChange(true)
onShow: () => this.emitQuickOpenVisibilityChange(true),
onHide: () => {
this.restoreFocus(); // focus back to editor or viewlet
this.emitQuickOpenVisibilityChange(false); // event
}
}, {
inputPlaceHolder: options.placeHolder || ''
},
Expand Down

0 comments on commit 5dbc95b

Please sign in to comment.