Skip to content

Commit ba205ad

Browse files
authored
Merge pull request #858 from Garulf/delete-folder-paths
Ctrl + Backspace in Query goes up directory path
2 parents 0e9830d + 9848e2a commit ba205ad

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
using NotifyIcon = System.Windows.Forms.NotifyIcon;
1919
using Flow.Launcher.Infrastructure;
2020
using System.Windows.Media;
21+
using Flow.Launcher.Infrastructure.Hotkey;
22+
using Flow.Launcher.Plugin.SharedCommands;
2123

2224
namespace Flow.Launcher
2325
{
@@ -499,6 +501,20 @@ private void OnKeyDown(object sender, KeyEventArgs e)
499501
e.Handled = true;
500502
}
501503
break;
504+
case Key.Back:
505+
var specialKeyState = GlobalHotkey.CheckModifiers();
506+
if (specialKeyState.CtrlPressed)
507+
{
508+
if (_viewModel.SelectedIsFromQueryResults()
509+
&& QueryTextBox.CaretIndex == QueryTextBox.Text.Length
510+
&& FilesFolders.IsLocationPathString(QueryTextBox.Text))
511+
{
512+
513+
_viewModel.BackspaceCommand.Execute(null);
514+
e.Handled = true;
515+
}
516+
}
517+
break;
502518
default:
503519
break;
504520

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
using Flow.Launcher.Infrastructure.Storage;
1414
using Flow.Launcher.Infrastructure.UserSettings;
1515
using Flow.Launcher.Plugin;
16+
using Flow.Launcher.Plugin.SharedCommands;
1617
using Flow.Launcher.Storage;
1718
using Flow.Launcher.Infrastructure.Logger;
1819
using Microsoft.VisualStudio.Threading;
1920
using System.Threading.Channels;
2021
using ISavable = Flow.Launcher.Plugin.ISavable;
2122

22-
2323
namespace Flow.Launcher.ViewModel
2424
{
2525
public class MainViewModel : BaseModel, ISavable
@@ -252,6 +252,14 @@ private void InitializeKeyCommands()
252252
}
253253
});
254254

255+
BackspaceCommand = new RelayCommand(index =>
256+
{
257+
var path = QueryText;
258+
259+
// GetPreviousExistingDirectory does not require trailing '\', otherwise will return empty string
260+
ChangeQueryText(FilesFolders.GetPreviousExistingDirectory(FilesFolders.IsLocationPathString, path.TrimEnd('\\')));
261+
});
262+
255263
LoadContextMenuCommand = new RelayCommand(_ =>
256264
{
257265
if (SelectedIsFromQueryResults())
@@ -398,6 +406,7 @@ private ResultsViewModel SelectedResults
398406
public string PluginIconPath { get; set; } = null;
399407

400408
public ICommand EscCommand { get; set; }
409+
public ICommand BackspaceCommand { get; set; }
401410
public ICommand SelectNextItemCommand { get; set; }
402411
public ICommand SelectPrevItemCommand { get; set; }
403412
public ICommand SelectNextPageCommand { get; set; }

0 commit comments

Comments
 (0)