@@ -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,53 @@ 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+ {
1270+ newSuggestions . AddRange (
1271+ previousSearchQueries . Select ( query => new SuggestionModel ( query , true ) )
1272+ ) ;
1273+ }
1274+ }
1275+ else
1276+ {
1277+ var search = new FolderSearch
1278+ {
1279+ Query = OmnibarSearchModeText ,
1280+ Folder = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ,
1281+ MaxItemCount = 10 ,
1282+ } ;
1283+
1284+ var results = await search . SearchAsync ( ) ;
1285+ newSuggestions . AddRange ( results . Select ( result => new SuggestionModel ( result ) ) ) ;
1286+ }
1287+
1288+ // Remove outdated suggestions
1289+ var toRemove = OmnibarSearchModeSuggestionItems
1290+ . Where ( existing => ! newSuggestions . Any ( newItem => newItem . ItemPath == existing . ItemPath ) )
1291+ . ToList ( ) ;
1292+
1293+ foreach ( var item in toRemove )
1294+ OmnibarSearchModeSuggestionItems . Remove ( item ) ;
1295+
1296+ // Add new suggestions
1297+ var toAdd = newSuggestions
1298+ . Where ( newItem => ! OmnibarSearchModeSuggestionItems . Any ( existing => existing . ItemPath == newItem . ItemPath ) ) ;
1299+
1300+ foreach ( var item in toAdd )
1301+ OmnibarSearchModeSuggestionItems . Add ( item ) ;
1302+ }
1303+
1304+
12461305 [ Obsolete ( "Remove once Omnibar goes out of experimental." ) ]
12471306 public async Task SetAddressBarSuggestionsAsync ( AutoSuggestBox sender , IShellPage shellpage )
12481307 {
0 commit comments