Skip to content

Commit

Permalink
matchOnDescription, matchOnDetail, ignoreFocusLost options (#45589)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Mar 26, 2018
1 parent 3f0f7c0 commit 0cea187
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/vs/workbench/browser/parts/quickinput/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.$;

Expand All @@ -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<object[]>) => void;

constructor(
@IEnvironmentService private environmentService: IEnvironmentService,
@IConfigurationService private configurationService: IConfigurationService,
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
Expand Down Expand Up @@ -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);
}
}));
Expand Down Expand Up @@ -157,7 +160,7 @@ export class QuickInputService extends Component implements IQuickInputService {
this.container.style.display = 'none';
}

async pick<T extends IPickOpenEntry>(picks: TPromise<T[]>, options?: IPickOptions, token?: CancellationToken): TPromise<T[]> {
async pick<T extends IPickOpenEntry>(picks: TPromise<T[]>, options: IPickOptions = {}, token?: CancellationToken): TPromise<T[]> {
this.create();
this.quickOpenService.close();
if (this.resolve) {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export class QuickInputCheckboxList {
private container: HTMLElement;
private list: WorkbenchList<SelectableElement>;
private elements: SelectableElement[] = [];
matchOnDescription = false;
matchOnDetail = false;
private _onAllVisibleSelectedChanged = new Emitter<boolean>(); // TODO: Debounce
onAllVisibleSelectedChanged: Event<boolean> = this._onAllVisibleSelectedChanged.event;
private _onSelectedCountChanged = new Emitter<number>(); // TODO: Debounce
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0cea187

Please sign in to comment.