@@ -1,5 +1,5 @@
11use crate::{
2− compositor::{Component, Compositor, Context, EventResult},
2+ compositor::{Callback, Component, Compositor, Context, EventResult},
33 ctrl, key, shift,
44};
55use crossterm::event::Event;
@@ -205,16 +205,16 @@ impl<T: Item + 'static> Component for Menu<T> {
205205 _ => return EventResult::Ignored(None),
206206 };
207207
208− let close_fn = EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor, _| {
208+ let close_fn: Option<Callback> = Some(Box::new(|compositor: &mut Compositor, _| {
209209 // remove the layer
210210 compositor.pop();
211− })));
211+ }));
212212
213213 match event.into() {
214214 // esc or ctrl-c aborts the completion and closes the menu
215215 key!(Esc) | ctrl!('c') => {
216216 (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Abort);
217− return close_fn;
217+ return EventResult::Consumed(close_fn);
218218 }
219219 // arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc)
220220 shift!(Tab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
@@ -231,8 +231,10 @@ impl<T: Item + 'static> Component for Menu<T> {
231231 key!(Enter) => {
232232 if let Some(selection) = self.selection() {
233233 (self.callback_fn)(cx.editor, Some(selection), MenuEvent::Validate);
234+ return EventResult::Consumed(close_fn);
235+ } else {
236+ return EventResult::Ignored(close_fn);
234237 }
235− return close_fn;
236238 }
237239 // KeyEvent {
238240 // code: KeyCode::Char(c),