diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index 1839da47..d67a429e 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -1,5 +1,5 @@ use crate::{ - compositor::{Component, Compositor, Context, EventResult}, + compositor::{Callback, Component, Compositor, Context, EventResult}, ctrl, key, shift, }; use crossterm::event::Event; @@ -205,16 +205,16 @@ impl Component for Menu { _ => return EventResult::Ignored(None), }; - let close_fn = EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor, _| { + let close_fn: Option = Some(Box::new(|compositor: &mut Compositor, _| { // remove the layer compositor.pop(); - }))); + })); match event.into() { // esc or ctrl-c aborts the completion and closes the menu key!(Esc) | ctrl!('c') => { (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Abort); - return close_fn; + return EventResult::Consumed(close_fn); } // arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc) shift!(Tab) | key!(Up) | ctrl!('p') | ctrl!('k') => { @@ -231,8 +231,10 @@ impl Component for Menu { key!(Enter) => { if let Some(selection) = self.selection() { (self.callback_fn)(cx.editor, Some(selection), MenuEvent::Validate); + return EventResult::Consumed(close_fn); + } else { + return EventResult::Ignored(close_fn); } - return close_fn; } // KeyEvent { // code: KeyCode::Char(c),