diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 86d1c7a2289a426a11ebc0695be90f038b7d8278..93552cf0e671723d63a4f029a04706bdd26b4fd4 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -1569,7 +1569,6 @@ declare module 'vscode' { /** * An optional function that is invoked whenever an item is selected. - * (Only honored when the picker does not allow multiple selections.) */ onDidSelectItem?(item: QuickPickItem | string): any; } diff --git a/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts b/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts index a3b4d16d8b5b61fee45cabbf0586b71a20560eb2..c84d6a8e5f342ca2c3838a8e7ec013eafa3d7e53 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts @@ -54,29 +54,29 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape { }; }); - return asWinJsPromise(token => { - if (options.canSelectMany) { - return this._quickInputService.pick(this._contents, options, token) - .then(items => { - if (items) { - return items.map(item => item.handle); - } - return undefined; - }); - } else { - return this._quickOpenService.pick(this._contents, options, token) - .then(item => { - if (item) { - return item.handle; - } - return undefined; - }); - } - }).then(undefined, undefined, progress => { - if (progress) { - this._proxy.$onItemSelected((progress).handle); - } - }); + if (options.canSelectMany) { + return asWinJsPromise(token => this._quickInputService.pick(this._contents, options, token)).then(items => { + if (items) { + return items.map(item => item.handle); + } + return undefined; + }, undefined, progress => { + if (progress) { + this._proxy.$onItemSelected((progress).handle); + } + }); + } else { + return asWinJsPromise(token => this._quickOpenService.pick(this._contents, options, token)).then(item => { + if (item) { + return item.handle; + } + return undefined; + }, undefined, progress => { + if (progress) { + this._proxy.$onItemSelected((progress).handle); + } + }); + } } $setItems(items: MyQuickPickItems[]): TPromise { diff --git a/src/vs/workbench/browser/parts/quickinput/quickInput.ts b/src/vs/workbench/browser/parts/quickinput/quickInput.ts index 457cd6e1dc03a8e4f488788ae252aa6927a0fe32..03ded3fde5349a720a9207c7bcf42627df90ea14 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInput.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInput.ts @@ -50,6 +50,7 @@ export class QuickInputService extends Component implements IQuickInputService { private ignoreFocusLost = false; private resolve: (value?: IPickOpenEntry[] | Thenable) => void; + private progress: (value: IPickOpenEntry) => void; constructor( @IEnvironmentService private environmentService: IEnvironmentService, @@ -126,6 +127,11 @@ export class QuickInputService extends Component implements IQuickInputService { this.inputBox.setFocus(); }, 0); })); + this.toUnbind.push(this.checkboxList.onFocusChange(e => { + if (this.progress && e.length) { + this.progress(e[0]); + } + })); this.toUnbind.push(dom.addDisposableListener(this.container, 'focusout', (e: FocusEvent) => { for (let element = e.relatedTarget; element; element = element.parentElement) { @@ -187,7 +193,10 @@ export class QuickInputService extends Component implements IQuickInputService { this.updateLayout(); this.inputBox.setFocus(); - const result = new TPromise(resolve => this.resolve = resolve); + const result = new TPromise((resolve, reject, progress) => { + this.resolve = resolve; + this.progress = progress; + }); const d = token.onCancellationRequested(() => this.close()); result.then(() => d.dispose(), () => d.dispose()); diff --git a/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts b/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts index 801d46c0a9d62768af0c7fed993d3954a8d55169..a4328d29cf0213569a3aa4d7ceff129ea5ffe5b1 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts @@ -15,7 +15,7 @@ import { IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen'; import { IMatch } from 'vs/base/common/filters'; import { matchesFuzzyOcticonAware, parseOcticons } from 'vs/base/common/octicon'; import { compareAnything } from 'vs/base/common/comparers'; -import { Emitter, Event } from 'vs/base/common/event'; +import { Emitter, Event, mapEvent } from 'vs/base/common/event'; import { assign } from 'vs/base/common/objects'; import { KeyCode } from 'vs/base/common/keyCodes'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; @@ -181,6 +181,10 @@ export class QuickInputCheckboxList { })); } + get onFocusChange() { + return mapEvent(this.list.onFocusChange, e => e.elements.map(e => e.item)); + } + getAllVisibleSelected() { return !this.elements.some(element => !element.hidden && !element.selected); }