Skip to content

Commit 5dbc95b

Browse files
author
Benjamin Pasero
committed
window.showQuickPick is not closed when promise is rejected
1 parent 4a85ac5 commit 5dbc95b

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/vs/workbench/api/browser/pluginHostQuickOpen.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ export class PluginHostQuickOpen {
6767
return items[handle];
6868
}
6969
});
70+
}, (err) => {
71+
this._proxy._setError(err);
72+
73+
return TPromise.wrapError(err);
7074
});
7175
}
7276

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

8185
private _quickOpenService: IQuickOpenService;
8286
private _doSetItems: (items: MyQuickPickItems[]) => any;
87+
private _doSetError: (error: Error) => any;
8388
private _contents: TPromise<MyQuickPickItems[]>;
8489
private _token = 0;
8590

@@ -97,6 +102,12 @@ export class MainThreadQuickOpen {
97102
c(items);
98103
}
99104
};
105+
106+
this._doSetError = (error) => {
107+
if (myToken === this._token) {
108+
e(error);
109+
}
110+
};
100111
});
101112

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

127+
_setError(error: Error): Thenable<any> {
128+
if (this._doSetError) {
129+
this._doSetError(error);
130+
return;
131+
}
132+
}
133+
116134
_input(options?: InputBoxOptions): Thenable<string> {
117135
return this._quickOpenService.input(options);
118136
}

src/vs/workbench/browser/parts/quickopen/quickOpenController.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
209209
onOk: () => { /* ignore, handle later */ },
210210
onCancel: () => { /* ignore, handle later */ },
211211
onType: (value: string) => { /* ignore, handle later */ },
212-
onShow: () => this.emitQuickOpenVisibilityChange(true)
212+
onShow: () => this.emitQuickOpenVisibilityChange(true),
213+
onHide: () => {
214+
this.restoreFocus(); // focus back to editor or viewlet
215+
this.emitQuickOpenVisibilityChange(false); // event
216+
}
213217
}, {
214218
inputPlaceHolder: options.placeHolder || ''
215219
},

0 commit comments

Comments
 (0)