diff options
author | Koichi Murase <myoga.murase@gmail.com> | 2024-02-14 17:54:44 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 08:54:44 +0000 |
commit | 063d9054d74c0c44781507eed27378415ab9fef5 (patch) | |
tree | 941d06ab49f58bda1fe1d06761700c027eadae9f | |
parent | 1a432b61ee4f52f3ff0da1c991aa5d605f700869 (diff) |
feat(search): process Ctrl+m for kitty keyboard protocol (#1720)
Fixes https://github.com/atuinsh/atuin/issues/1719
[C-m] is usually identical to [RET] in the terminal protocol, and some
users use [C-m] in place of [RET]. However, kitty's extended keyboard
protocol enables differentiating them so that [C-m] does not function
as does without the extended keyboard protocol.
For the compatibility with terminals without extended keyboard
protocols, we anyway cannot assign a distinct feature to [C-m], so we
can safely add the explicit binding of InputAction::Accept to [C-m].
-rw-r--r-- | atuin/src/command/client/search/interactive.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs index 7680ce53..1c71a5b6 100644 --- a/atuin/src/command/client/search/interactive.rs +++ b/atuin/src/command/client/search/interactive.rs @@ -243,6 +243,13 @@ impl State { self.handle_search_scroll_one_line(settings, enable_exit, !settings.invert) } + fn handle_search_accept(&mut self, settings: &Settings) -> InputAction { + if settings.enter_accept { + self.accept = true; + } + InputAction::Accept(self.results_state.selected()) + } + #[allow(clippy::too_many_lines)] #[allow(clippy::cognitive_complexity)] fn handle_search_input(&mut self, settings: &Settings, input: &KeyEvent) -> InputAction { @@ -305,13 +312,8 @@ impl State { } match input.code { - KeyCode::Enter => { - if settings.enter_accept { - self.accept = true; - } - - return InputAction::Accept(self.results_state.selected()); - } + KeyCode::Enter => return self.handle_search_accept(settings), + KeyCode::Char('m') if ctrl => return self.handle_search_accept(settings), KeyCode::Char('y') if ctrl => { return InputAction::Copy(self.results_state.selected()); } |