@@ -1035,6 +1035,18 @@ private void SavePathToHistory(string path)
10351035 UserSettingsService . GeneralSettingsService . PathHistoryList = pathHistoryList ;
10361036 }
10371037
1038+ public void SaveSearchQueryToList ( string searchQuery )
1039+ {
1040+ var previousSearchQueriesList = UserSettingsService . GeneralSettingsService . PreviousSearchQueriesList ? . ToList ( ) ?? [ ] ;
1041+ previousSearchQueriesList . Remove ( searchQuery ) ;
1042+ previousSearchQueriesList . Insert ( 0 , searchQuery ) ;
1043+
1044+ if ( previousSearchQueriesList . Count > MaxSuggestionsCount )
1045+ UserSettingsService . GeneralSettingsService . PreviousSearchQueriesList = previousSearchQueriesList . RemoveFrom ( MaxSuggestionsCount + 1 ) ;
1046+ else
1047+ UserSettingsService . GeneralSettingsService . PreviousSearchQueriesList = previousSearchQueriesList ;
1048+ }
1049+
10381050 private static async Task < bool > LaunchApplicationFromPath ( string currentInput , string workingDir )
10391051 {
10401052 var args = CommandLineParser . SplitArguments ( currentInput ) ;
@@ -1243,6 +1255,49 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
12431255 }
12441256 }
12451257
1258+ public async Task PopulateOmnibarSuggestionsForSearchMode ( )
1259+ {
1260+ if ( ContentPageContext . ShellPage is null )
1261+ return ;
1262+
1263+ List < SuggestionModel > newSuggestions = [ ] ;
1264+
1265+ if ( string . IsNullOrWhiteSpace ( OmnibarSearchModeText ) )
1266+ {
1267+ var previousSearchQueries = UserSettingsService . GeneralSettingsService . PreviousSearchQueriesList ;
1268+ if ( previousSearchQueries is not null )
1269+ newSuggestions . AddRange ( previousSearchQueries . Select ( query => new SuggestionModel ( query , true ) ) ) ;
1270+ }
1271+ else
1272+ {
1273+ var search = new FolderSearch
1274+ {
1275+ Query = OmnibarSearchModeText ,
1276+ Folder = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ,
1277+ MaxItemCount = 10 ,
1278+ } ;
1279+
1280+ var results = await search . SearchAsync ( ) ;
1281+ newSuggestions . AddRange ( results . Select ( result => new SuggestionModel ( result ) ) ) ;
1282+ }
1283+
1284+ // Remove outdated suggestions
1285+ var toRemove = OmnibarSearchModeSuggestionItems
1286+ . Where ( existing => ! newSuggestions . Any ( newItem => newItem . ItemPath == existing . ItemPath ) )
1287+ . ToList ( ) ;
1288+
1289+ foreach ( var item in toRemove )
1290+ OmnibarSearchModeSuggestionItems . Remove ( item ) ;
1291+
1292+ // Add new suggestions
1293+ var toAdd = newSuggestions
1294+ . Where ( newItem => ! OmnibarSearchModeSuggestionItems . Any ( existing => existing . Name == newItem . Name ) ) ;
1295+
1296+ foreach ( var item in toAdd )
1297+ OmnibarSearchModeSuggestionItems . Add ( item ) ;
1298+ }
1299+
1300+
12461301 [ Obsolete ( "Remove once Omnibar goes out of experimental." ) ]
12471302 public async Task SetAddressBarSuggestionsAsync ( AutoSuggestBox sender , IShellPage shellpage )
12481303 {
0 commit comments