Skip to content

Commit

Permalink
Fix escape not exiting insert mode
Browse files Browse the repository at this point in the history
Regression due to helix-editor#635 where escape key in insert mode
would not exit normal mode. This happened due to hard
coding the escape key to cancel a sticky keymap node.
  • Loading branch information
sudormrfbin committed Sep 5, 2021
1 parent 183dcce commit 76ca86a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,14 @@ impl Keymap {
/// sticky node is in use, it will be cleared.
pub fn get(&mut self, key: KeyEvent) -> KeymapResult {
if let key!(Esc) = key {
if self.state.is_empty() {
self.sticky = None;
if !self.state.is_empty() {
return KeymapResult::new(
// Note that Esc is not included here
KeymapResultKind::Cancelled(self.state.drain(..).collect()),
self.sticky(),
);
}
return KeymapResult::new(
KeymapResultKind::Cancelled(self.state.drain(..).collect()),
self.sticky(),
);
self.sticky = None;
}

let first = self.state.get(0).unwrap_or(&key);
Expand Down

0 comments on commit 76ca86a

Please sign in to comment.