@@ -78,6 +78,8 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
78
78
79
79
internal ObservableCollection < NavigationBarSuggestionItem > OmnibarCommandPaletteModeSuggestionItems { get ; } = [ ] ;
80
80
81
+ internal ObservableCollection < SuggestionModel > OmnibarSearchModeSuggestionItems { get ; } = [ ] ;
82
+
81
83
public bool IsSingleItemOverride { get ; set ; }
82
84
83
85
public bool SearchHasFocus { get ; private set ; }
@@ -231,66 +233,14 @@ public string? PathText
231
233
private string ? _OmnibarCommandPaletteModeText ;
232
234
public string ? OmnibarCommandPaletteModeText { get => _OmnibarCommandPaletteModeText ; set => SetProperty ( ref _OmnibarCommandPaletteModeText , value ) ; }
233
235
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 ) ; }
266
238
267
239
private string _OmnibarCurrentSelectedModeName = OmnibarPathModeName ;
268
240
public string OmnibarCurrentSelectedModeName
269
241
{
270
242
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 ) ;
294
244
}
295
245
296
246
private CurrentInstanceViewModel _InstanceViewModel ;
@@ -1100,8 +1050,6 @@ private static async Task<bool> LaunchApplicationFromPath(string currentInput, s
1100
1050
1101
1051
public async Task PopulateOmnibarSuggestionsForPathMode ( )
1102
1052
{
1103
- PathModeSuggestionItems . Clear ( ) ;
1104
-
1105
1053
var result = await SafetyExtensions . IgnoreExceptions ( ( Func < Task < bool > > ) ( async ( ) =>
1106
1054
{
1107
1055
List < OmnibarPathModeSuggestionModel > ? newSuggestions = [ ] ;
@@ -1200,49 +1148,41 @@ void AddNoResultsItem()
1200
1148
1201
1149
public void PopulateOmnibarSuggestionsForCommandPaletteMode ( )
1202
1150
{
1203
- OmnibarCommandPaletteModeText ??= string . Empty ;
1204
- OmnibarCommandPaletteModeSuggestionItems . Clear ( ) ;
1205
-
1206
1151
if ( ContentPageContext . SelectedItems . Count == 1 && ContentPageContext . SelectedItem is not null && ! ContentPageContext . SelectedItem . IsFolder )
1207
1152
{
1208
- var dispatcherQueue = Microsoft . UI . Dispatching . DispatcherQueue . GetForCurrentThread ( ) ;
1209
-
1210
- dispatcherQueue . TryEnqueue ( ( ) =>
1153
+ try
1211
1154
{
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 ) ) )
1213
1160
{
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
+ } ;
1217
1167
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 ) )
1219
1169
{
1220
- var newItem = new NavigationBarSuggestionItem
1170
+ try
1221
1171
{
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 )
1228
1175
{
1229
- try
1230
- {
1231
- newItem . ActionIconSource = new BitmapImage ( validUri ) ;
1232
- }
1233
- catch ( Exception )
1234
- {
1235
- }
1236
1176
}
1237
-
1238
- OmnibarCommandPaletteModeSuggestionItems . Add ( newItem ) ;
1239
1177
}
1178
+
1179
+ OmnibarCommandPaletteModeSuggestionItems . Add ( newItem ) ;
1240
1180
}
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
+ }
1246
1186
}
1247
1187
1248
1188
var suggestionItems = Commands
0 commit comments