@@ -919,7 +919,7 @@ export const enum SearchResultIdx {
919
919
920
920
export class SearchResultModel extends SettingsTreeModel {
921
921
private rawSearchResults : ISearchResult [ ] | null = null ;
922
- private cachedUniqueSearchResults : ISearchResult | null = null ;
922
+ private cachedUniqueSearchResults : Map < boolean , ISearchResult | null > ;
923
923
private newExtensionSearchResults : ISearchResult | null = null ;
924
924
private searchResultCount : number | null = null ;
925
925
private settingsOrderByTocIndex : Map < string , number > | null ;
@@ -939,11 +939,13 @@ export class SearchResultModel extends SettingsTreeModel {
939
939
) {
940
940
super ( viewState , isWorkspaceTrusted , configurationService , languageService , userDataProfileService , productService ) ;
941
941
this . settingsOrderByTocIndex = settingsOrderByTocIndex ;
942
+ this . cachedUniqueSearchResults = new Map ( ) ;
942
943
this . update ( { id : 'searchResultModel' , label : '' } ) ;
943
944
}
944
945
945
946
set showAiResults ( show : boolean ) {
946
947
this . aiFilterEnabled = show ;
948
+ this . updateChildren ( ) ;
947
949
}
948
950
949
951
private sortResults ( filterMatches : ISettingMatch [ ] ) : ISettingMatch [ ] {
@@ -986,8 +988,9 @@ export class SearchResultModel extends SettingsTreeModel {
986
988
}
987
989
988
990
getUniqueSearchResults ( ) : ISearchResult | null {
989
- if ( this . cachedUniqueSearchResults ) {
990
- return this . cachedUniqueSearchResults ;
991
+ const cachedResults = this . cachedUniqueSearchResults . get ( this . aiFilterEnabled ) ;
992
+ if ( cachedResults ) {
993
+ return cachedResults ;
991
994
}
992
995
993
996
if ( ! this . rawSearchResults ) {
@@ -1009,33 +1012,35 @@ export class SearchResultModel extends SettingsTreeModel {
1009
1012
embeddingsResult . filterMatches = embeddingsResult . filterMatches . filter ( m => ! aiSelectedKeys . has ( m . setting . key ) ) ;
1010
1013
combinedFilterMatches = combinedFilterMatches . concat ( embeddingsResult . filterMatches ) ;
1011
1014
}
1012
- this . cachedUniqueSearchResults = {
1015
+ const result = {
1013
1016
filterMatches : combinedFilterMatches ,
1014
1017
exactMatch : false
1015
1018
} ;
1016
- } else {
1017
- const localMatchKeys = new Set < string > ( ) ;
1018
- const localResult = this . rawSearchResults [ SearchResultIdx . Local ] ;
1019
- if ( localResult ) {
1020
- localResult . filterMatches . forEach ( m => localMatchKeys . add ( m . setting . key ) ) ;
1021
- combinedFilterMatches = localResult . filterMatches ;
1022
- }
1023
-
1024
- const remoteResult = this . rawSearchResults [ SearchResultIdx . Remote ] ;
1025
- if ( remoteResult ) {
1026
- remoteResult . filterMatches = remoteResult . filterMatches . filter ( m => ! localMatchKeys . has ( m . setting . key ) ) ;
1027
- combinedFilterMatches = combinedFilterMatches . concat ( remoteResult . filterMatches ) ;
1019
+ this . cachedUniqueSearchResults . set ( true , result ) ;
1020
+ return result ;
1021
+ }
1028
1022
1029
- this . newExtensionSearchResults = this . rawSearchResults [ SearchResultIdx . NewExtensions ] ;
1030
- }
1031
- combinedFilterMatches = this . sortResults ( combinedFilterMatches ) ;
1032
- this . cachedUniqueSearchResults = {
1033
- filterMatches : combinedFilterMatches ,
1034
- exactMatch : localResult . exactMatch // remote results should never have an exact match
1035
- } ;
1023
+ const localMatchKeys = new Set < string > ( ) ;
1024
+ const localResult = this . rawSearchResults [ SearchResultIdx . Local ] ;
1025
+ if ( localResult ) {
1026
+ localResult . filterMatches . forEach ( m => localMatchKeys . add ( m . setting . key ) ) ;
1027
+ combinedFilterMatches = localResult . filterMatches ;
1036
1028
}
1037
1029
1038
- return this . cachedUniqueSearchResults ;
1030
+ const remoteResult = this . rawSearchResults [ SearchResultIdx . Remote ] ;
1031
+ if ( remoteResult ) {
1032
+ remoteResult . filterMatches = remoteResult . filterMatches . filter ( m => ! localMatchKeys . has ( m . setting . key ) ) ;
1033
+ combinedFilterMatches = combinedFilterMatches . concat ( remoteResult . filterMatches ) ;
1034
+
1035
+ this . newExtensionSearchResults = this . rawSearchResults [ SearchResultIdx . NewExtensions ] ;
1036
+ }
1037
+ combinedFilterMatches = this . sortResults ( combinedFilterMatches ) ;
1038
+ const result = {
1039
+ filterMatches : combinedFilterMatches ,
1040
+ exactMatch : localResult . exactMatch // remote results should never have an exact match
1041
+ } ;
1042
+ this . cachedUniqueSearchResults . set ( false , result ) ;
1043
+ return result ;
1039
1044
}
1040
1045
1041
1046
getRawResults ( ) : ISearchResult [ ] {
@@ -1089,7 +1094,7 @@ export class SearchResultModel extends SettingsTreeModel {
1089
1094
}
1090
1095
1091
1096
setResult ( order : SearchResultIdx , result : ISearchResult | null ) : void {
1092
- this . cachedUniqueSearchResults = null ;
1097
+ this . cachedUniqueSearchResults . clear ( ) ;
1093
1098
this . newExtensionSearchResults = null ;
1094
1099
1095
1100
this . rawSearchResults ??= [ ] ;
0 commit comments