Skip to content

Commit e302d2c

Browse files
committed
Invoke a command when a suggestion was clicked
1 parent 6de1e9c commit e302d2c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ private async void Omnibar_SuggestionChosen(Omnibar sender, OmnibarSuggestionCho
278278
}
279279
else if (Omnibar.CurrentSelectedMode == OmnibarCommandPaletteMode)
280280
{
281+
if (args.SelectedItem is not NavigationBarSuggestionItem item || item.Text is not { } commandText)
282+
return;
283+
284+
var command = Commands[commandText];
285+
if (command == Commands.None)
286+
await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidCommand.GetLocalizedResource(),
287+
string.Format(Strings.InvalidCommandContent.GetLocalizedResource(), commandText));
288+
else if (!command.IsExecutable)
289+
await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocalizedResource(),
290+
string.Format(Strings.CommandNotExecutableContent.GetLocalizedResource(), command.Code));
291+
else
292+
await command.ExecuteAsync();
293+
294+
ViewModel.OmnibarCommandPaletteModeText = string.Empty;
281295
}
282296
else if (Omnibar.CurrentSelectedMode == OmnibarSearchMode)
283297
{

0 commit comments

Comments
 (0)