@@ -78,6 +78,8 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
7878
7979 internal ObservableCollection < NavigationBarSuggestionItem > OmnibarCommandPaletteModeSuggestionItems { get ; } = [ ] ;
8080
81+ internal ObservableCollection < SuggestionModel > OmnibarSearchModeSuggestionItems { get ; } = [ ] ;
82+
8183 public bool IsSingleItemOverride { get ; set ; }
8284
8385 public bool SearchHasFocus { get ; private set ; }
@@ -231,66 +233,14 @@ public string? PathText
231233 private string ? _OmnibarCommandPaletteModeText ;
232234 public string ? OmnibarCommandPaletteModeText { get => _OmnibarCommandPaletteModeText ; set => SetProperty ( ref _OmnibarCommandPaletteModeText , value ) ; }
233235
234- private bool _IsOmnibarFocused ;
235- public bool IsOmnibarFocused
236- {
237- get => _IsOmnibarFocused ;
238- set
239- {
240- // NOTE: Don't call ObservableObject.SetProperty() here since we don't want to change focus logic outside of the control.
241-
242- _IsOmnibarFocused = value ;
243-
244- if ( value )
245- {
246- switch ( OmnibarCurrentSelectedModeName )
247- {
248- case OmnibarPathModeName :
249- PathText =
250- string . IsNullOrEmpty ( ContentPageContext . ShellPage ? . ShellViewModel ? . WorkingDirectory )
251- ? Constants . UserEnvironmentPaths . HomePath
252- : ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
253- _ = PopulateOmnibarSuggestionsForPathMode ( ) ;
254- break ;
255- case OmnibarPaletteModeName :
256- PopulateOmnibarSuggestionsForCommandPaletteMode ( ) ;
257- break ;
258- case OmnibarSearchModeName :
259- break ;
260- default :
261- break ;
262- }
263- }
264- }
265- }
236+ private string ? _OmnibarSearchModeText ;
237+ public string ? OmnibarSearchModeText { get => _OmnibarSearchModeText ; set => SetProperty ( ref _OmnibarSearchModeText , value ) ; }
266238
267239 private string _OmnibarCurrentSelectedModeName = OmnibarPathModeName ;
268240 public string OmnibarCurrentSelectedModeName
269241 {
270242 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- }
243+ set => SetProperty ( ref _OmnibarCurrentSelectedModeName , value ) ;
294244 }
295245
296246 private CurrentInstanceViewModel _InstanceViewModel ;
@@ -1100,8 +1050,6 @@ private static async Task<bool> LaunchApplicationFromPath(string currentInput, s
11001050
11011051 public async Task PopulateOmnibarSuggestionsForPathMode ( )
11021052 {
1103- PathModeSuggestionItems . Clear ( ) ;
1104-
11051053 var result = await SafetyExtensions . IgnoreExceptions ( ( Func < Task < bool > > ) ( async ( ) =>
11061054 {
11071055 List < OmnibarPathModeSuggestionModel > ? newSuggestions = [ ] ;
@@ -1200,49 +1148,41 @@ void AddNoResultsItem()
12001148
12011149 public void PopulateOmnibarSuggestionsForCommandPaletteMode ( )
12021150 {
1203- OmnibarCommandPaletteModeText ??= string . Empty ;
1204- OmnibarCommandPaletteModeSuggestionItems . Clear ( ) ;
1205-
12061151 if ( ContentPageContext . SelectedItems . Count == 1 && ContentPageContext . SelectedItem is not null && ! ContentPageContext . SelectedItem . IsFolder )
12071152 {
1208- var dispatcherQueue = Microsoft . UI . Dispatching . DispatcherQueue . GetForCurrentThread ( ) ;
1209-
1210- dispatcherQueue . TryEnqueue ( ( ) =>
1153+ try
12111154 {
1212- try
1155+ var selectedItemPath = ContentPageContext . SelectedItem . ItemPath ;
1156+ var fileActionEntity = ActionManager . Instance . EntityFactory . CreateFileEntity ( selectedItemPath ) ;
1157+ var actions = ActionManager . Instance . ActionRuntime . ActionCatalog . GetActionsForInputs ( new [ ] { fileActionEntity } ) ;
1158+
1159+ foreach ( var action in actions . Where ( a => a . Definition . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
12131160 {
1214- var selectedItemPath = ContentPageContext . SelectedItem . ItemPath ;
1215- var fileActionEntity = ActionManager . Instance . EntityFactory . CreateFileEntity ( selectedItemPath ) ;
1216- var actions = ActionManager . Instance . ActionRuntime . ActionCatalog . GetActionsForInputs ( new [ ] { fileActionEntity } ) ;
1161+ var newItem = new NavigationBarSuggestionItem
1162+ {
1163+ PrimaryDisplay = action . Definition . Description ,
1164+ SearchText = OmnibarCommandPaletteModeText ,
1165+ ActionInstance = action
1166+ } ;
12171167
1218- foreach ( var action in actions . Where ( a => a . Definition . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
1168+ if ( Uri . TryCreate ( action . Definition . IconFullPath , UriKind . RelativeOrAbsolute , out Uri ? validUri ) )
12191169 {
1220- var newItem = new NavigationBarSuggestionItem
1170+ try
12211171 {
1222- PrimaryDisplay = action . Definition . Description ,
1223- SearchText = OmnibarCommandPaletteModeText ,
1224- ActionInstance = action
1225- } ;
1226-
1227- if ( Uri . TryCreate ( action . Definition . IconFullPath , UriKind . RelativeOrAbsolute , out Uri ? validUri ) )
1172+ newItem . ActionIconSource = new BitmapImage ( validUri ) ;
1173+ }
1174+ catch ( Exception )
12281175 {
1229- try
1230- {
1231- newItem . ActionIconSource = new BitmapImage ( validUri ) ;
1232- }
1233- catch ( Exception )
1234- {
1235- }
12361176 }
1237-
1238- OmnibarCommandPaletteModeSuggestionItems . Add ( newItem ) ;
12391177 }
1178+
1179+ OmnibarCommandPaletteModeSuggestionItems . Add ( newItem ) ;
12401180 }
1241- catch ( Exception ex )
1242- {
1243- App . Logger . LogWarning ( ex , ex . Message ) ;
1244- }
1245- } ) ;
1181+ }
1182+ catch ( Exception ex )
1183+ {
1184+ App . Logger . LogWarning ( ex , ex . Message ) ;
1185+ }
12461186 }
12471187
12481188 var suggestionItems = Commands
0 commit comments