diff --git a/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts b/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts index 01edb6072c1a71cc4ceb46dd4ce3da0a10766a54..3793973a9fd6223c55ca5ddc2cb9939db8e83a26 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts @@ -84,6 +84,8 @@ export class SettingsEditor2 extends BaseEditor { private inSettingsEditorContextKey: IContextKey; private searchFocusContextKey: IContextKey; + private tagRegex = /(^|\s)@tag:("([^"]*)"|[^"]\S*)/g; + /** Don't spam warnings */ private hasWarnedMissingSettings: boolean; @@ -181,10 +183,10 @@ export class SettingsEditor2 extends BaseEditor { this.searchWidget.clear(); } - filterByTag(tag: string): void { + search(text: string): void { if (this.searchWidget) { this.searchWidget.focus(); - this.searchWidget.setValue(`@tag:${tag} `); + this.searchWidget.setValue(text); } } @@ -233,7 +235,7 @@ export class SettingsEditor2 extends BaseEditor { const actions = [ this.instantiationService.createInstance(FilterByTagAction, - localize('filterModifiedLabel', "Show modified settings only"), + localize('filterModifiedLabel', "Show modified settings"), MODIFIED_SETTING_TAG, this), this.instantiationService.createInstance( @@ -664,12 +666,16 @@ export class SettingsEditor2 extends BaseEditor { private triggerSearch(query: string): TPromise { this.viewState.tagFilters = new Set(); if (query) { - const tagMatches = query.match(/\s*@tag:(\S+)(.*)/); // For now, we support single tag at a time. - if (tagMatches) { - this.viewState.tagFilters.add(tagMatches[1]); - query = tagMatches[2]; - } + query = query.replace(this.tagRegex, (_, __, quotedTag, tag) => { + this.viewState.tagFilters.add(tag || quotedTag); + return ''; + }); + query = query.replace(`@${MODIFIED_SETTING_TAG}`, () => { + this.viewState.tagFilters.add(MODIFIED_SETTING_TAG); + return ''; + }); } + query = query.trim(); if (query) { return this.searchInProgress = TPromise.join([ this.localSearchDelayer.trigger(() => this.localFilterPreferences(query)), @@ -856,7 +862,7 @@ class FilterByTagAction extends Action { } run(): TPromise { - this.settingsEditor.filterByTag(this.tag); + this.settingsEditor.search(this.tag === MODIFIED_SETTING_TAG ? `@${this.tag} ` : `@tag:${this.tag} `); return TPromise.as(null); } } diff --git a/src/vs/workbench/parts/preferences/browser/settingsTree.ts b/src/vs/workbench/parts/preferences/browser/settingsTree.ts index e1dfd2f0e4fdb90eedbcffcd091398b63d493bd4..7f0205c640eeb0c9cb99f2f2230a596cf3787c4b 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsTree.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsTree.ts @@ -1181,11 +1181,9 @@ export class SettingsTreeFilter implements IFilter { if (element instanceof SettingsTreeSettingElement && this.viewState.tagFilters && this.viewState.tagFilters.size) { if (element.tags) { - let hasFilteredTag = false; - element.tags.forEach(tag => { - if (this.viewState.tagFilters.has(tag)) { - hasFilteredTag = true; - } + let hasFilteredTag = true; + this.viewState.tagFilters.forEach(tag => { + hasFilteredTag = hasFilteredTag && element.tags.has(tag); }); return hasFilteredTag; } else {