From 6957b5ab7b98c3f090131e9388c18c1826812314 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Tue, 19 Mar 2024 05:04:17 -0500 Subject: [PATCH] Revert "Move left when exiting insert mode (#699)" (#773) Simulating vim's cursor logic by moving the actual cursor breaks the history traversal. Thus revert. This reverts commit 02f551d42eeda2f277cb98416bb035529b2a91aa. --- src/edit_mode/vi/mod.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/edit_mode/vi/mod.rs b/src/edit_mode/vi/mod.rs index c687a86b..4428c645 100644 --- a/src/edit_mode/vi/mod.rs +++ b/src/edit_mode/vi/mod.rs @@ -136,17 +136,8 @@ impl EditMode for Vi { } (_, KeyModifiers::NONE, KeyCode::Esc) => { self.cache.clear(); - - ReedlineEvent::Multiple(vec![ - if self.mode == ViMode::Insert { - self.mode = ViMode::Normal; - ReedlineEvent::Left - } else { - ReedlineEvent::None - }, - ReedlineEvent::Esc, - ReedlineEvent::Repaint, - ]) + self.mode = ViMode::Normal; + ReedlineEvent::Multiple(vec![ReedlineEvent::Esc, ReedlineEvent::Repaint]) } (_, KeyModifiers::NONE, KeyCode::Enter) => { self.mode = ViMode::Insert; @@ -197,11 +188,7 @@ mod test { assert_eq!( result, - ReedlineEvent::Multiple(vec![ - ReedlineEvent::Left, - ReedlineEvent::Esc, - ReedlineEvent::Repaint - ]) + ReedlineEvent::Multiple(vec![ReedlineEvent::Esc, ReedlineEvent::Repaint]) ); assert!(matches!(vi.mode, ViMode::Normal)); }