Skip to content

Commit 520d237

Browse files
authored
Merge pull request #987 from Flow-Launcher/update_back_prev_dir_logic
[Dev] Add support for action keyword when using Ctrl + Backspace
2 parents ba205ad + 9161de2 commit 520d237

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,16 @@ private void OnKeyDown(object sender, KeyEventArgs e)
506506
if (specialKeyState.CtrlPressed)
507507
{
508508
if (_viewModel.SelectedIsFromQueryResults()
509-
&& QueryTextBox.CaretIndex == QueryTextBox.Text.Length
510-
&& FilesFolders.IsLocationPathString(QueryTextBox.Text))
509+
&& QueryTextBox.CaretIndex == QueryTextBox.Text.Length)
511510
{
512-
513-
_viewModel.BackspaceCommand.Execute(null);
514-
e.Handled = true;
511+
var queryWithoutActionKeyword =
512+
QueryBuilder.Build(QueryTextBox.Text.Trim(), PluginManager.NonGlobalPlugins).Search;
513+
514+
if (FilesFolders.IsLocationPathString(queryWithoutActionKeyword))
515+
{
516+
_viewModel.BackspaceCommand.Execute(null);
517+
e.Handled = true;
518+
}
515519
}
516520
}
517521
break;

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,14 @@ private void InitializeKeyCommands()
254254

255255
BackspaceCommand = new RelayCommand(index =>
256256
{
257-
var path = QueryText;
257+
var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins);
258258

259259
// GetPreviousExistingDirectory does not require trailing '\', otherwise will return empty string
260-
ChangeQueryText(FilesFolders.GetPreviousExistingDirectory(FilesFolders.IsLocationPathString, path.TrimEnd('\\')));
260+
var path = FilesFolders.GetPreviousExistingDirectory((_) => true, query.Search.TrimEnd('\\'));
261+
262+
var actionKeyword = string.IsNullOrEmpty(query.ActionKeyword) ? string.Empty : $"{query.ActionKeyword} ";
263+
264+
ChangeQueryText($"{actionKeyword}{path}");
261265
});
262266

263267
LoadContextMenuCommand = new RelayCommand(_ =>

Flow.Launcher/ViewModel/ResultsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,4 @@ public void Update(List<ResultViewModel> newItems, CancellationToken token = def
310310
}
311311
}
312312
}
313-
}
313+
}

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,18 @@ And you can download <a href="https://github.com/Flow-Launcher/Flow.Launcher/dis
215215

216216
| Hotkey | Description |
217217
| ------------------------------------------------------------ | -------------------------------------------- |
218-
| <kbd>Alt</kbd>+ <kbd>Space</kbd> | Open Search Box (Default and Configurable) |
218+
| <kbd>Alt</kbd>+ <kbd>Space</kbd> | Open Search Box (default and configurable) |
219219
| <kbd>Enter</kbd> | Execute |
220220
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Enter</kbd> | Run As Admin |
221221
| <kbd>↑</kbd><kbd>↓</kbd> | Scroll up & Down |
222222
| <kbd>←</kbd><kbd>→</kbd> | Back to Result / Open Context Menu |
223-
| <kbd>Ctrl</kbd> +<kbd>o</kbd> , <kbd>Shift</kbd> +<kbd>Enter</kbd> | Open Context Menu |
224-
| <kbd>Tab</kbd> | Autocomplete |
223+
| <kbd>Ctrl</kbd> +<kbd>o</kbd> , <kbd>Shift</kbd> +<kbd>Enter</kbd> | Open Context Menu |
224+
| <kbd>Tab</kbd> | Autocomplete |
225225
| <kbd>Esc</kbd> | Back to Result & Close |
226226
| <kbd>Ctrl</kbd> +<kbd>i</kbd> | Open Setting Window |
227227
| <kbd>F5</kbd> | Reload All Plugin Data & Window Search Index |
228228
| <kbd>Ctrl</kbd> + <kbd>h</kbd> | Open Query History |
229+
| <kbd>Ctrl</kbd> + <kbd>Backspace</kbd> | Back to Previous Directory |
229230

230231

231232
## System Command List

0 commit comments

Comments
 (0)