From 419e2721285a3d026b1e1424ceffc7a16fd51677 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Tue, 11 Jun 2024 21:08:42 -0500 Subject: [PATCH] Support autojump in popup SelectView For now, only support autojump when the popup is closed, and not inside the menu popup itself. Note that autojump fires the select callback, while popup mode previously only fired the submit callback. --- cursive-core/src/views/select_view.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cursive-core/src/views/select_view.rs b/cursive-core/src/views/select_view.rs index 449b2f9b..7c5886c9 100644 --- a/cursive-core/src/views/select_view.rs +++ b/cursive-core/src/views/select_view.rs @@ -814,7 +814,8 @@ impl SelectView { }) } - // A popup view only does one thing: open the popup on Enter. + // A popup view opens the popup on Enter, and also applies autojump if + // enabled. fn on_event_popup(&mut self, event: Event) -> EventResult { match event { // TODO: add Left/Right support for quick-switch? @@ -824,6 +825,7 @@ impl SelectView { position, offset, } if position.fits_in_rect(offset, self.last_size) => self.open_popup(), + Event::Char(c) if self.autojump => return self.on_char_event(c), _ => EventResult::Ignored, } }