From 350081a3af9a4cd87f177289d54feb8861b1313e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 24 Mar 2021 18:15:42 +0900 Subject: [PATCH] Fix crash if pressing enter when nothing selected in completion. --- helix-term/src/ui/menu.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index e9893588..049d6170 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -140,7 +140,9 @@ impl Component for Menu { code: KeyCode::Enter, .. } => { - (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Validate); + if let Some(selection) = self.selection() { + (self.callback_fn)(cx.editor, Some(selection), MenuEvent::Validate); + } return close_fn; } // KeyEvent {