aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-24 09:15:42 +0000
committerBlaž Hrastnik2021-03-24 09:15:42 +0000
commit350081a3af9a4cd87f177289d54feb8861b1313e (patch)
tree471f5b0d9b1ea45d3fecd0053fe53db276c44c9e
parent8657c57cf2d56b9a89e2f780675426f4c78df48b (diff)
Fix crash if pressing enter when nothing selected in completion.
-rw-r--r--helix-term/src/ui/menu.rs4
1 files changed, 3 insertions, 1 deletions
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<T> Component for Menu<T> {
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 {