Fix search result count again (#180453)

This commit is contained in:
Raymond Zhao 2023-04-20 16:12:53 -07:00 committed by GitHub
parent 4a4980ca8d
commit 175cd6b50d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View file

@ -1555,6 +1555,8 @@ export class SettingsEditor2 extends EditorPane {
if (!this.searchResultModel) {
this.searchResultModel = this.instantiationService.createInstance(SearchResultModel, this.viewState, this.workspaceTrustManagementService.isWorkspaceTrusted());
// Must be called before this.renderTree()
// to make sure the search results count is set.
this.searchResultModel.setResult(type, result);
this.tocTreeModel.currentSearchModel = this.searchResultModel;
this.onSearchModeToggled();
@ -1596,9 +1598,7 @@ export class SettingsEditor2 extends EditorPane {
this.rootElement.classList.remove('no-results');
this.splitView.el.style.visibility = 'visible';
return;
}
if (this.tocTreeModel && this.tocTreeModel.settingsTreeRoot) {
} else {
const count = this.searchResultModel.getUniqueResultsCount();
let resultString: string;
switch (count) {

View file

@ -808,6 +808,7 @@ export class SearchResultModel extends SettingsTreeModel {
private rawSearchResults: ISearchResult[] | null = null;
private cachedUniqueSearchResults: ISearchResult[] | null = null;
private newExtensionSearchResults: ISearchResult | null = null;
private searchResultCount: number | null = null;
readonly id = 'searchResultModel';
@ -853,13 +854,6 @@ export class SearchResultModel extends SettingsTreeModel {
return this.rawSearchResults || [];
}
getUniqueResultsCount(): number {
const uniqueResults = this.getUniqueResults();
const localResultsCount = uniqueResults[0]?.filterMatches.length ?? 0;
const remoteResultsCount = uniqueResults[1]?.filterMatches.length ?? 0;
return localResultsCount + remoteResultsCount;
}
setResult(order: SearchResultIdx, result: ISearchResult | null): void {
this.cachedUniqueSearchResults = null;
this.newExtensionSearchResults = null;
@ -890,6 +884,7 @@ export class SearchResultModel extends SettingsTreeModel {
this.root.children = this.root.children
.filter(child => child instanceof SettingsTreeSettingElement && child.matchesAllTags(this._viewState.tagFilters) && child.matchesScope(this._viewState.settingsTarget, isRemote) && child.matchesAnyExtension(this._viewState.extensionFilters) && child.matchesAnyId(this._viewState.idFilters) && child.matchesAnyFeature(this._viewState.featureFilters) && child.matchesAllLanguages(this._viewState.languageFilter));
this.searchResultCount = this.root.children.length;
if (this.newExtensionSearchResults?.filterMatches.length) {
let resultExtensionIds = this.newExtensionSearchResults.filterMatches
@ -906,6 +901,10 @@ export class SearchResultModel extends SettingsTreeModel {
}
}
getUniqueResultsCount(): number {
return this.searchResultCount ?? 0;
}
private getFlatSettings(): ISetting[] {
const flatSettings: ISetting[] = [];
arrays.coalesce(this.getUniqueResults())