From f92998a14b3017371c6a55756c60c03e126ae23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 14 Dec 2020 15:59:48 +0900 Subject: [PATCH] Prompt needs to close on enter. --- helix-term/src/ui/prompt.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 3ca1a9411..f5ef94779 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -151,6 +151,11 @@ fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult { _ => return EventResult::Ignored, }; + let close_fn = EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor| { + // remove the layer + compositor.pop(); + }))); + match event { KeyEvent { code: KeyCode::Char(c), @@ -159,10 +164,7 @@ fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult { KeyEvent { code: KeyCode::Esc, .. } => { - return EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor| { - // remove the layer - compositor.pop(); - }))); + return close_fn; } KeyEvent { code: KeyCode::Right, @@ -187,7 +189,10 @@ fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult { KeyEvent { code: KeyCode::Enter, .. - } => (self.callback_fn)(cx.editor, &self.line), + } => { + (self.callback_fn)(cx.editor, &self.line); + return close_fn; + } KeyEvent { code: KeyCode::Tab, .. } => self.change_completion_selection(),