44using CommunityToolkit . WinUI ;
55using Files . App . Controls ;
66using Files . Shared . Helpers ;
7+ using Microsoft . Extensions . Logging ;
78using Microsoft . UI . Dispatching ;
89using Microsoft . UI . Xaml ;
910using Microsoft . UI . Xaml . Controls ;
@@ -242,7 +243,7 @@ public bool IsOmnibarFocused
242243
243244 if ( value )
244245 {
245- switch ( OmnibarCurrentSelectedMode . Name )
246+ switch ( OmnibarCurrentSelectedModeName )
246247 {
247248 case OmnibarPathModeName :
248249 PathText =
@@ -263,11 +264,34 @@ public bool IsOmnibarFocused
263264 }
264265 }
265266
266- private OmnibarMode _OmnibarCurrentSelectedMode ;
267- public OmnibarMode OmnibarCurrentSelectedMode { get => _OmnibarCurrentSelectedMode ; set => SetProperty ( ref _OmnibarCurrentSelectedMode , value ) ; }
268-
269- private string _OmnibarCurrentSelectedModeName ;
270- public string OmnibarCurrentSelectedModeName { get => _OmnibarCurrentSelectedModeName ; set => SetProperty ( ref _OmnibarCurrentSelectedModeName , value ) ; }
267+ private string _OmnibarCurrentSelectedModeName = OmnibarPathModeName ;
268+ public string OmnibarCurrentSelectedModeName
269+ {
270+ get => _OmnibarCurrentSelectedModeName ;
271+ set
272+ {
273+ if ( SetProperty ( ref _OmnibarCurrentSelectedModeName , value ) && IsOmnibarFocused )
274+ {
275+ switch ( value )
276+ {
277+ case OmnibarPathModeName :
278+ PathText =
279+ string . IsNullOrEmpty ( ContentPageContext . ShellPage ? . ShellViewModel ? . WorkingDirectory )
280+ ? Constants . UserEnvironmentPaths . HomePath
281+ : ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
282+ _ = PopulateOmnibarSuggestionsForPathMode ( ) ;
283+ break ;
284+ case OmnibarPaletteModeName :
285+ PopulateOmnibarSuggestionsForCommandPaletteMode ( ) ;
286+ break ;
287+ case OmnibarSearchModeName :
288+ break ;
289+ default :
290+ break ;
291+ }
292+ }
293+ }
294+ }
271295
272296 private CurrentInstanceViewModel _InstanceViewModel ;
273297 public CurrentInstanceViewModel InstanceViewModel
@@ -738,7 +762,6 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLoca
738762 }
739763
740764 PathControlDisplayText = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
741- IsOmnibarFocused = false ;
742765 }
743766
744767 public void PathBoxItem_PreviewKeyDown ( object sender , KeyRoutedEventArgs e )
@@ -1077,6 +1100,8 @@ private static async Task<bool> LaunchApplicationFromPath(string currentInput, s
10771100
10781101 public async Task PopulateOmnibarSuggestionsForPathMode ( )
10791102 {
1103+ PathModeSuggestionItems . Clear ( ) ;
1104+
10801105 var result = await SafetyExtensions . IgnoreExceptions ( ( Func < Task < bool > > ) ( async ( ) =>
10811106 {
10821107 List < OmnibarPathModeSuggestionModel > ? newSuggestions = [ ] ;
@@ -1117,9 +1142,7 @@ public async Task PopulateOmnibarSuggestionsForPathMode()
11171142
11181143 // If there are no suggestions, show "No suggestions"
11191144 if ( newSuggestions . Count is 0 )
1120- {
1121- AddNoResultsItem ( ) ;
1122- }
1145+ return false ;
11231146
11241147 // Check whether at least one item is in common between the old and the new suggestions
11251148 // since the suggestions popup becoming empty causes flickering
0 commit comments