diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 57b34bc009c..f3360d9a98a 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -18,6 +18,8 @@ using NotifyIcon = System.Windows.Forms.NotifyIcon; using Flow.Launcher.Infrastructure; using System.Windows.Media; +using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher { @@ -499,6 +501,20 @@ private void OnKeyDown(object sender, KeyEventArgs e) e.Handled = true; } break; + case Key.Back: + var specialKeyState = GlobalHotkey.CheckModifiers(); + if (specialKeyState.CtrlPressed) + { + if (_viewModel.SelectedIsFromQueryResults() + && QueryTextBox.CaretIndex == QueryTextBox.Text.Length + && FilesFolders.IsLocationPathString(QueryTextBox.Text)) + { + + _viewModel.BackspaceCommand.Execute(null); + e.Handled = true; + } + } + break; default: break; diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 2391e622cd6..a3691e98e30 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -13,13 +13,13 @@ using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; +using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Storage; using Flow.Launcher.Infrastructure.Logger; using Microsoft.VisualStudio.Threading; using System.Threading.Channels; using ISavable = Flow.Launcher.Plugin.ISavable; - namespace Flow.Launcher.ViewModel { public class MainViewModel : BaseModel, ISavable @@ -252,6 +252,14 @@ private void InitializeKeyCommands() } }); + BackspaceCommand = new RelayCommand(index => + { + var path = QueryText; + + // GetPreviousExistingDirectory does not require trailing '\', otherwise will return empty string + ChangeQueryText(FilesFolders.GetPreviousExistingDirectory(FilesFolders.IsLocationPathString, path.TrimEnd('\\'))); + }); + LoadContextMenuCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) @@ -398,6 +406,7 @@ private ResultsViewModel SelectedResults public string PluginIconPath { get; set; } = null; public ICommand EscCommand { get; set; } + public ICommand BackspaceCommand { get; set; } public ICommand SelectNextItemCommand { get; set; } public ICommand SelectPrevItemCommand { get; set; } public ICommand SelectNextPageCommand { get; set; }