From afa057fe5146e00b5065b88b755a1764e2eb6bfe Mon Sep 17 00:00:00 2001 From: woojiq Date: Tue, 14 Jan 2025 22:45:41 +0200 Subject: [PATCH] [picker] feat: navigate backward and forward * Add and keybinds to navigate in the global search picker history. --- book/src/keymap.md | 2 ++ helix-term/src/ui/picker.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/book/src/keymap.md b/book/src/keymap.md index 2797eaee2..8a0bbe66f 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -456,6 +456,8 @@ See the documentation page on [pickers](./pickers.md) for more info. | `PageDown`, `Ctrl-d` | Page down | | `Home` | Go to first entry | | `End` | Go to last entry | +| `Alt-p` | Select previous history | +| `Alt-n` | Select next history | | `Enter` | Open selected | | `Alt-Enter` | Open selected in the background without closing the picker | | `Ctrl-s` | Open horizontally | diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index a6ce91a67..48057185c 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -1106,6 +1106,26 @@ impl Component for Picker { + if let Some(register) = self.prompt.history_register() { + self.prompt.change_history( + ctx, + register, + ui::prompt::CompletionDirection::Backward, + ); + self.handle_prompt_change(true); + } + } + alt!('n') => { + if let Some(register) = self.prompt.history_register() { + self.prompt.change_history( + ctx, + register, + ui::prompt::CompletionDirection::Forward, + ); + self.handle_prompt_change(true); + } + } ctrl!('s') => { if let Some(option) = self.selection() { (self.callback_fn)(ctx, option, Action::HorizontalSplit);