Skip to content

Commit

Permalink
Move left when exiting insert mode
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Stan <[email protected]>
  • Loading branch information
andreistan26 committed Feb 9, 2024
1 parent ab1b47e commit edb2614
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/edit_mode/vi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,17 @@ impl EditMode for Vi {
}
(_, KeyModifiers::NONE, KeyCode::Esc) => {
self.cache.clear();
self.mode = ViMode::Normal;
ReedlineEvent::Multiple(vec![ReedlineEvent::Esc, ReedlineEvent::Repaint])

Check warning on line 139 in src/edit_mode/vi/mod.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, bashisms)

Diff in /home/runner/work/reedline/reedline/src/edit_mode/vi/mod.rs

Check warning on line 139 in src/edit_mode/vi/mod.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, default)

Diff in /home/runner/work/reedline/reedline/src/edit_mode/vi/mod.rs

Check warning on line 139 in src/edit_mode/vi/mod.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, sqlite)

Diff in /home/runner/work/reedline/reedline/src/edit_mode/vi/mod.rs

Check warning on line 139 in src/edit_mode/vi/mod.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, basqlite)

Diff in /home/runner/work/reedline/reedline/src/edit_mode/vi/mod.rs

Check warning on line 139 in src/edit_mode/vi/mod.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, external_printer)

Diff in /home/runner/work/reedline/reedline/src/edit_mode/vi/mod.rs
ReedlineEvent::Multiple(vec![
if self.mode == ViMode::Insert {
self.mode = ViMode::Normal;
ReedlineEvent::Left
} else {
ReedlineEvent::None
},
ReedlineEvent::Esc,
ReedlineEvent::Repaint,
])
}
(_, KeyModifiers::NONE, KeyCode::Enter) => {
self.mode = ViMode::Insert;
Expand Down Expand Up @@ -188,7 +197,11 @@ mod test {

assert_eq!(
result,
ReedlineEvent::Multiple(vec![ReedlineEvent::Esc, ReedlineEvent::Repaint])
ReedlineEvent::Multiple(vec![
ReedlineEvent::Left,
ReedlineEvent::Esc,
ReedlineEvent::Repaint
])
);
assert!(matches!(vi.mode, ViMode::Normal));
}
Expand Down

0 comments on commit edb2614

Please sign in to comment.