fix(help): repaint and close searchable overlay

Fixes #1559.
This commit is contained in:
Hunter Bown
2026-05-13 00:09:15 -05:00
parent 2e022bda25
commit 5fa372202c
2 changed files with 25 additions and 0 deletions
+1
View File
@@ -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,
+24
View File
@@ -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();