From 03ae0b868e8f89b9e3a70826be946ed1eacca354 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 20 Jan 2022 07:43:00 +1100 Subject: [PATCH] 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 a9ea3d08f..93119ecf1 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -18,6 +18,7 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs; 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 @@ namespace Flow.Launcher { 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 f6d55e91f..9b0b4355a 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -20,7 +20,6 @@ using Flow.Launcher.Infrastructure.Logger; 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 @@ namespace Flow.Launcher.ViewModel 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(_ =>