diff --git a/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts b/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts index 14ef50470e27ad935fb06f109af0e6406d4e9985..cd7d9207aae1b502f08590869c90820d125a792f 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts @@ -76,7 +76,7 @@ export class SettingsEditor2 extends BaseEditor { private delayedFilterLogging: Delayer; private localSearchDelayer: Delayer; private remoteSearchThrottle: ThrottledDelayer; - private searchCancelToken: CancellationTokenSource; + private searchInProgress: CancellationTokenSource; private delayRefreshOnLayout: Delayer; private lastLayedoutWidth: number; @@ -747,6 +747,11 @@ export class SettingsEditor2 extends BaseEditor { }); } + private parseSettingFromJSON(query: string): string { + const match = query.match(/"([a-zA-Z.]+)": /); + return match && match[1]; + } + private triggerSearch(query: string): TPromise { this.viewState.tagFilters = new Set(); if (query) { @@ -762,14 +767,16 @@ export class SettingsEditor2 extends BaseEditor { query = query.trim(); if (query && query !== '@') { - this.searchCancelToken = new CancellationTokenSource(); + query = this.parseSettingFromJSON(query) || query; + + this.searchInProgress = new CancellationTokenSource(); return TPromise.join([ - this.localSearchDelayer.trigger(() => this.localFilterPreferences(query, this.searchCancelToken.token)), - this.remoteSearchThrottle.trigger(() => this.remoteSearchPreferences(query, this.searchCancelToken.token), 500) + this.localSearchDelayer.trigger(() => this.searchInProgress ? this.localFilterPreferences(query, this.searchInProgress.token) : TPromise.wrap(null)), + this.remoteSearchThrottle.trigger(() => this.searchInProgress ? this.remoteSearchPreferences(query, this.searchInProgress.token) : TPromise.wrap(null), 500) ]).then(() => { - if (this.searchCancelToken) { - this.searchCancelToken.dispose(); - this.searchCancelToken = null; + if (this.searchInProgress) { + this.searchInProgress.dispose(); + this.searchInProgress = null; } }); } else { @@ -781,10 +788,10 @@ export class SettingsEditor2 extends BaseEditor { this.localSearchDelayer.cancel(); this.remoteSearchThrottle.cancel(); - if (this.searchCancelToken) { - this.searchCancelToken.cancel(); - this.searchCancelToken.dispose(); - this.searchCancelToken = null; + if (this.searchInProgress) { + this.searchInProgress.cancel(); + this.searchInProgress.dispose(); + this.searchInProgress = null; } this.viewState.filterToCategory = null; diff --git a/src/vs/workbench/parts/preferences/browser/settingsTreeModels.ts b/src/vs/workbench/parts/preferences/browser/settingsTreeModels.ts index a603d2906ccb48e85fe8278c86f9a033194a0038..9de906b243f85a7c2076693918178425f9d1ceba 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsTreeModels.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsTreeModels.ts @@ -429,7 +429,7 @@ export class SearchResultModel extends SettingsTreeModel { settings: this.getFlatSettings() }); - if (this.newExtensionSearchResults) { + if (this.newExtensionSearchResults && this.newExtensionSearchResults.filterMatches.length) { const newExtElement = new SettingsTreeNewExtensionsElement(); newExtElement.parent = this._root; newExtElement.id = 'newExtensions'; diff --git a/src/vs/workbench/parts/preferences/browser/tocTree.ts b/src/vs/workbench/parts/preferences/browser/tocTree.ts index 48702ecc7b238366723c10ca91d5742aff2a4916..e15e90024d918e3da368f07793933b0a463a1cc0 100644 --- a/src/vs/workbench/parts/preferences/browser/tocTree.ts +++ b/src/vs/workbench/parts/preferences/browser/tocTree.ts @@ -49,15 +49,21 @@ export class TOCTreeModel { } private updateGroupCount(group: SettingsTreeGroupElement): void { - group.count = this._currentSearchModel ? - this.getSearchResultChildrenCount(group) : - undefined; - group.children.forEach(child => { if (child instanceof SettingsTreeGroupElement) { this.updateGroupCount(child); } }); + + if (this._currentSearchModel) { + const childCount = group.children + .filter(child => child instanceof SettingsTreeGroupElement) + .reduce((acc, cur) => acc + (cur).count, 0); + + group.count = childCount + this.getSearchResultChildrenCount(group); + } else { + group.count = undefined; + } } private getSearchResultChildrenCount(group: SettingsTreeGroupElement): number { @@ -70,8 +76,6 @@ export class TOCTreeModel { return group.children.some(child => { if (child instanceof SettingsTreeSettingElement) { return child.setting.key === setting.key && child.matchesAllTags(this.viewState.tagFilters); - } else if (child instanceof SettingsTreeGroupElement) { - return this.groupContainsSetting(child, setting); } else { return false; }