From 5fa372202c98f03bf506b727494cf737e8395d76 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Wed, 13 May 2026 00:09:15 -0500 Subject: [PATCH] fix(help): repaint and close searchable overlay Fixes #1559. --- crates/tui/src/tui/ui.rs | 1 + crates/tui/src/tui/views/help.rs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/tui/src/tui/ui.rs b/crates/tui/src/tui/ui.rs index 1bc7bcca..42ec28d0 100644 --- a/crates/tui/src/tui/ui.rs +++ b/crates/tui/src/tui/ui.rs @@ -2370,6 +2370,7 @@ async fn run_event_loop( if !app.view_stack.is_empty() { let events = app.view_stack.handle_key(key); + app.needs_redraw = true; if handle_view_events( terminal, app, diff --git a/crates/tui/src/tui/views/help.rs b/crates/tui/src/tui/views/help.rs index 2b3105e9..dda016af 100644 --- a/crates/tui/src/tui/views/help.rs +++ b/crates/tui/src/tui/views/help.rs @@ -246,6 +246,10 @@ impl ModalView for HelpView { fn handle_key(&mut self, key: KeyEvent) -> ViewAction { match key.code { KeyCode::Esc => ViewAction::Close, + KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => { + ViewAction::Close + } + KeyCode::Char('q') | KeyCode::Char('Q') if self.query.is_empty() => ViewAction::Close, KeyCode::Up => { self.move_selection(-1); ViewAction::None @@ -576,6 +580,26 @@ mod tests { assert!(matches!(action, ViewAction::Close)); } + #[test] + fn ctrl_c_closes_overlay() { + let mut view = HelpView::new(); + let action = view.handle_key(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL)); + assert!(matches!(action, ViewAction::Close)); + } + + #[test] + fn q_closes_empty_filter_but_types_when_filtering() { + let mut view = HelpView::new(); + let action = view.handle_key(key(KeyCode::Char('q'))); + assert!(matches!(action, ViewAction::Close)); + + let mut view = HelpView::new(); + type_filter(&mut view, "mod"); + let action = view.handle_key(key(KeyCode::Char('q'))); + assert!(matches!(action, ViewAction::None)); + assert_eq!(view.query, "modq"); + } + #[test] fn arrow_keys_move_selection_within_bounds() { let mut view = HelpView::new();