Skip to content

Commit be8f527

Browse files
committed
Code Quality: Use action description when selecting via arrow keys
1 parent a69c610 commit be8f527

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/Files.App/UserControls/NavigationToolbar.xaml.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,21 +269,25 @@ private async void Omnibar_QuerySubmitted(Omnibar sender, OmnibarQuerySubmittedE
269269
return;
270270

271271
// Try invoking built-in command
272-
if (item.Text is { } commandText)
272+
foreach (IRichCommand command in Commands)
273273
{
274-
var command = Commands[commandText];
275-
if (command == Commands.None)
276-
await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidCommand.GetLocalizedResource(),
277-
string.Format(Strings.InvalidCommandContent.GetLocalizedResource(), commandText));
278-
else if (!command.IsExecutable)
279-
await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocalizedResource(),
280-
string.Format(Strings.CommandNotExecutableContent.GetLocalizedResource(), command.Code));
281-
else
282-
await command.ExecuteAsync();
274+
if (item.Text == command.Description)
275+
{
276+
if (command == Commands.None)
277+
await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidCommand.GetLocalizedResource(),
278+
string.Format(Strings.InvalidCommandContent.GetLocalizedResource(), command.Code));
279+
else if (!command.IsExecutable)
280+
await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocalizedResource(),
281+
string.Format(Strings.CommandNotExecutableContent.GetLocalizedResource(), command.Code));
282+
else
283+
await command.ExecuteAsync();
284+
285+
return;
286+
}
283287
}
284288

285289
// Try invoking Windows app action
286-
else if (ActionManager.Instance.ActionRuntime is not null && item.ActionInstance is ActionInstance actionInstance)
290+
if (ActionManager.Instance.ActionRuntime is not null && item.ActionInstance is ActionInstance actionInstance)
287291
{
288292
// Workaround for https://github.com/microsoft/App-Actions-On-Windows-Samples/issues/7
289293
var action = ActionManager.Instance.ActionRuntime.ActionCatalog.GetAllActions()

src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,15 +1254,15 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
12541254
{
12551255
ThemedIconStyle = command.Glyph.ToThemedIconStyle(),
12561256
Glyph = command.Glyph.BaseGlyph,
1257-
Text = command.Code.ToString(),
1257+
Text = command.Description,
12581258
PrimaryDisplay = command.Description,
12591259
HotKeys = command.HotKeys,
12601260
SearchText = OmnibarCommandPaletteModeText,
12611261
});
12621262

12631263
foreach (var item in suggestionItems)
12641264
{
1265-
if (item.Text != Commands.OpenCommandPalette.Code.ToString())
1265+
if (item.Text != Commands.OpenCommandPalette.Description.ToString())
12661266
OmnibarCommandPaletteModeSuggestionItems.Add(item);
12671267
}
12681268

0 commit comments

Comments
 (0)