Skip to content

Commit

Permalink
feat(search): process Ctrl+m for kitty keyboard protocol
Browse files Browse the repository at this point in the history
Fixes atuinsh#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].
  • Loading branch information
akinomyoga committed Feb 14, 2024
1 parent 1a432b6 commit 0d1f443
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions atuin/src/command/client/search/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 0d1f443

Please sign in to comment.