Fix crash if pressing enter when nothing selected in completion.

This commit is contained in:
Blaž Hrastnik 2021-03-24 18:15:42 +09:00
parent 8657c57cf2
commit 350081a3af

View file

@ -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 {