diff --git a/src/edit_mode/vi/mod.rs b/src/edit_mode/vi/mod.rs index de6bf7227..a3204adb2 100644 --- a/src/edit_mode/vi/mod.rs +++ b/src/edit_mode/vi/mod.rs @@ -159,18 +159,29 @@ impl EditMode for Vi { self.mode = ViMode::Normal; ReedlineEvent::Multiple(vec![ReedlineEvent::Esc, ReedlineEvent::Repaint]) } - (_, KeyModifiers::NONE, KeyCode::Enter) => { - self.mode = ViMode::Insert; - ReedlineEvent::Enter - } (ViMode::Normal | ViMode::Visual, _, _) => self .normal_keybindings .find_binding(modifiers, code) - .unwrap_or(ReedlineEvent::None), + .unwrap_or_else(|| { + // Default Enter behavior when no custom binding + if modifiers == KeyModifiers::NONE && code == KeyCode::Enter { + self.mode = ViMode::Insert; + ReedlineEvent::Enter + } else { + ReedlineEvent::None + } + }), (ViMode::Insert, _, _) => self .insert_keybindings .find_binding(modifiers, code) - .unwrap_or(ReedlineEvent::None), + .unwrap_or_else(|| { + // Default Enter behavior when no custom binding + if modifiers == KeyModifiers::NONE && code == KeyCode::Enter { + ReedlineEvent::Enter + } else { + ReedlineEvent::None + } + }), }, Event::Mouse(_) => ReedlineEvent::Mouse,