Skip to content

Commit

Permalink
Esc should clear selection
Browse files Browse the repository at this point in the history
  • Loading branch information
deephbz committed Dec 31, 2024
1 parent bd443f4 commit 202d51e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/edit_mode/vi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ impl EditMode for Vi {
(_, KeyModifiers::NONE, KeyCode::Esc) => {
self.cache.clear();
self.mode = ViMode::Normal;
ReedlineEvent::Multiple(vec![ReedlineEvent::Esc, ReedlineEvent::Repaint])
ReedlineEvent::Multiple(vec![
ReedlineEvent::Edit(vec![EditCommand::MoveRight { select: false }, EditCommand::MoveLeft { select: false }]),
ReedlineEvent::Esc,
ReedlineEvent::Repaint
])
}
(_, KeyModifiers::NONE, KeyCode::Enter) => {
self.mode = ViMode::Insert;
Expand Down Expand Up @@ -191,7 +195,11 @@ mod test {

assert_eq!(
result,
ReedlineEvent::Multiple(vec![ReedlineEvent::Esc, ReedlineEvent::Repaint])
ReedlineEvent::Multiple(vec![
ReedlineEvent::Edit(vec![EditCommand::MoveRight { select: false }, EditCommand::MoveLeft { select: false }]),
ReedlineEvent::Esc,
ReedlineEvent::Repaint
])
);
assert!(matches!(vi.mode, ViMode::Normal));
}
Expand Down

0 comments on commit 202d51e

Please sign in to comment.