From 87c069bfafacef04a4a99f88516678aa3c706de9 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Fri, 3 Dec 2021 11:59:40 -0500 Subject: [PATCH 1/3] Initial commit --- Flow.Launcher/MainWindow.xaml.cs | 9 +++++++++ Flow.Launcher/ViewModel/MainViewModel.cs | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index ba0b63a5211..18a323cdf68 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -469,6 +469,15 @@ private void OnKeyDown(object sender, KeyEventArgs e) e.Handled = true; } break; + case Key.Back: + if (_viewModel.SelectedIsFromQueryResults() + && QueryTextBox.CaretIndex == QueryTextBox.Text.Length + && !string.IsNullOrEmpty(QueryTextBox.Text) && QueryTextBox.Text.Contains(":\\")) + { + _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 1d666426f7a..f6d55e91fa9 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -20,7 +20,7 @@ using Microsoft.VisualStudio.Threading; using System.Threading.Channels; using ISavable = Flow.Launcher.Plugin.ISavable; - +using System.IO; namespace Flow.Launcher.ViewModel { @@ -228,6 +228,11 @@ private void InitializeKeyCommands() } }); + BackspaceCommand = new RelayCommand(index => + { + ChangeQueryText(Path.GetDirectoryName(QueryText)); + }); + LoadContextMenuCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) @@ -371,6 +376,7 @@ private ResultsViewModel SelectedResults public double MainWindowWidth => _settings.WindowSize; 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; } From 0363cbcf740e1840154130353467e12419e593cc Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Fri, 3 Dec 2021 12:23:00 -0500 Subject: [PATCH 2/3] Only delete paths with CTRL --- Flow.Launcher/MainWindow.xaml.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 18a323cdf68..a9ea3d08fe3 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -17,6 +17,7 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs; using NotifyIcon = System.Windows.Forms.NotifyIcon; using Flow.Launcher.Infrastructure; +using Flow.Launcher.Infrastructure.Hotkey; namespace Flow.Launcher { @@ -470,12 +471,17 @@ private void OnKeyDown(object sender, KeyEventArgs e) } break; case Key.Back: - if (_viewModel.SelectedIsFromQueryResults() - && QueryTextBox.CaretIndex == QueryTextBox.Text.Length - && !string.IsNullOrEmpty(QueryTextBox.Text) && QueryTextBox.Text.Contains(":\\")) + var specialKeyState = GlobalHotkey.Instance.CheckModifiers(); + if (specialKeyState.CtrlPressed) { - _viewModel.BackspaceCommand.Execute(null); - e.Handled = true; + if (_viewModel.SelectedIsFromQueryResults() + && QueryTextBox.CaretIndex == QueryTextBox.Text.Length + && !string.IsNullOrEmpty(QueryTextBox.Text) && QueryTextBox.Text.Contains(":\\")) + { + + _viewModel.BackspaceCommand.Execute(null); + e.Handled = true; + } } break; default: From 03ae0b868e8f89b9e3a70826be946ed1eacca354 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 20 Jan 2022 07:43:00 +1100 Subject: [PATCH 3/3] use previous directory command --- Flow.Launcher/MainWindow.xaml.cs | 3 ++- Flow.Launcher/ViewModel/MainViewModel.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index a9ea3d08fe3..93119ecf1f6 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -18,6 +18,7 @@ using NotifyIcon = System.Windows.Forms.NotifyIcon; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher { @@ -476,7 +477,7 @@ private void OnKeyDown(object sender, KeyEventArgs e) { if (_viewModel.SelectedIsFromQueryResults() && QueryTextBox.CaretIndex == QueryTextBox.Text.Length - && !string.IsNullOrEmpty(QueryTextBox.Text) && QueryTextBox.Text.Contains(":\\")) + && FilesFolders.IsLocationPathString(QueryTextBox.Text)) { _viewModel.BackspaceCommand.Execute(null); diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index f6d55e91fa9..9b0b4355aab 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -20,7 +20,6 @@ using Microsoft.VisualStudio.Threading; using System.Threading.Channels; using ISavable = Flow.Launcher.Plugin.ISavable; -using System.IO; namespace Flow.Launcher.ViewModel { @@ -230,7 +229,10 @@ private void InitializeKeyCommands() BackspaceCommand = new RelayCommand(index => { - ChangeQueryText(Path.GetDirectoryName(QueryText)); + var path = QueryText; + + // GetPreviousExistingDirectory does not require trailing '\', otherwise will return empty string + ChangeQueryText(FilesFolders.GetPreviousExistingDirectory(FilesFolders.IsLocationPathString, path.TrimEnd('\\'))); }); LoadContextMenuCommand = new RelayCommand(_ =>