Merge pull request #858 from Garulf/delete-folder-paths

Ctrl + Backspace in Query goes up directory path
This commit is contained in:
Jeremy Wu 2022-01-20 08:02:07 +11:00 committed by GitHub
commit ba205ad18f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View file

@ -18,6 +18,8 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs;
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 @@ namespace Flow.Launcher
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;

View file

@ -13,13 +13,13 @@ using Flow.Launcher.Infrastructure.Hotkey;
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 @@ namespace Flow.Launcher.ViewModel
}
});
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 @@ namespace Flow.Launcher.ViewModel
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; }