From 0cea18743baf022df2af1728ff10c7169dc4f0d7 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Mon, 26 Mar 2018 11:14:11 +0200 Subject: [PATCH] matchOnDescription, matchOnDetail, ignoreFocusLost options (#45589) --- .../workbench/browser/parts/quickinput/quickInput.ts | 10 ++++++++-- .../browser/parts/quickinput/quickInputCheckboxList.ts | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/browser/parts/quickinput/quickInput.ts b/src/vs/workbench/browser/parts/quickinput/quickInput.ts index 0bf7fe80db0f0..959fb33bf2c63 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInput.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInput.ts @@ -27,6 +27,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { CLOSE_ON_FOCUS_LOST_CONFIG } from 'vs/workbench/browser/quickopen'; import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge'; import { attachBadgeStyler } from 'vs/platform/theme/common/styler'; +import { IEnvironmentService } from 'vs/platform/environment/common/environment'; const $ = dom.$; @@ -43,10 +44,12 @@ export class QuickInputService extends Component implements IQuickInputService { private inputBox: QuickInputBox; private count: CountBadge; private checkboxList: QuickInputCheckboxList; + private ignoreFocusLost = false; private resolve: (value?: object[] | Thenable) => void; constructor( + @IEnvironmentService private environmentService: IEnvironmentService, @IConfigurationService private configurationService: IConfigurationService, @IInstantiationService private instantiationService: IInstantiationService, @IPartService private partService: IPartService, @@ -125,7 +128,7 @@ export class QuickInputService extends Component implements IQuickInputService { return; } } - if (this.configurationService.getValue(CLOSE_ON_FOCUS_LOST_CONFIG)) { + if (!this.ignoreFocusLost && !this.environmentService.args['sticky-quickopen'] && this.configurationService.getValue(CLOSE_ON_FOCUS_LOST_CONFIG)) { this.close(false); } })); @@ -157,7 +160,7 @@ export class QuickInputService extends Component implements IQuickInputService { this.container.style.display = 'none'; } - async pick(picks: TPromise, options?: IPickOptions, token?: CancellationToken): TPromise { + async pick(picks: TPromise, options: IPickOptions = {}, token?: CancellationToken): TPromise { this.create(); this.quickOpenService.close(); if (this.resolve) { @@ -171,8 +174,11 @@ export class QuickInputService extends Component implements IQuickInputService { this.inputBox.setPlaceholder(options.placeHolder ? localize('quickInput.ctrlSpaceToSelectWithPlaceholder', "{1} ({0} to toggle)", 'Ctrl+Space', options.placeHolder) : localize('quickInput.ctrlSpaceToSelect', "{0} to toggle", 'Ctrl+Space')); // TODO: Progress indication. this.checkboxList.setElements(await picks); + this.checkboxList.matchOnDescription = options.matchOnDescription; + this.checkboxList.matchOnDetail = options.matchOnDetail; this.selectAll.checked = this.checkboxList.getAllVisibleSelected(); this.count.setCount(this.checkboxList.getSelectedCount()); + this.ignoreFocusLost = options.ignoreFocusLost; this.container.style.display = null; this.updateLayout(); diff --git a/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts b/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts index a90a82d2547a9..d33c2e7e0f609 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts @@ -143,6 +143,8 @@ export class QuickInputCheckboxList { private container: HTMLElement; private list: WorkbenchList; private elements: SelectableElement[] = []; + matchOnDescription = false; + matchOnDetail = false; private _onAllVisibleSelectedChanged = new Emitter(); // TODO: Debounce onAllVisibleSelectedChanged: Event = this._onAllVisibleSelectedChanged.event; private _onSelectedCountChanged = new Emitter(); // TODO: Debounce @@ -231,8 +233,8 @@ export class QuickInputCheckboxList { else { this.elements.forEach(element => { const labelHighlights = matchesFuzzyOcticonAware(query, parseOcticons(element.item.label)); - const descriptionHighlights = matchesFuzzyOcticonAware(query, parseOcticons(element.item.description || '')); - const detailHighlights = matchesFuzzyOcticonAware(query, parseOcticons(element.item.detail || '')); + const descriptionHighlights = this.matchOnDescription ? matchesFuzzyOcticonAware(query, parseOcticons(element.item.description || '')) : undefined; + const detailHighlights = this.matchOnDetail ? matchesFuzzyOcticonAware(query, parseOcticons(element.item.detail || '')) : undefined; if (element.shouldAlwaysShow || labelHighlights || descriptionHighlights || detailHighlights) { element.labelHighlights = labelHighlights;