[picker] feat: navigate backward and forward

* Add <A-p> and <A-n> keybinds to navigate in the global search picker
history.
pull/12536/head
woojiq 2025-01-14 22:45:41 +02:00
parent 7ebf650029
commit afa057fe51
2 changed files with 22 additions and 0 deletions

View File

@ -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 |

View File

@ -1106,6 +1106,26 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
return close_fn(self);
}
}
alt!('p') => {
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);