Skip to content

Commit

Permalink
Revert "Move left when exiting insert mode (#699)" (#773)
Browse files Browse the repository at this point in the history
Simulating vim's cursor logic by moving the actual cursor breaks the history traversal. Thus revert.

This reverts commit 02f551d.
  • Loading branch information
fdncred authored Mar 19, 2024
1 parent dc7063e commit 6957b5a
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/edit_mode/vi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 6957b5a

Please sign in to comment.