Fix escape not exiting insert mode (#712)

Regression due to #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.
imgbot
Gokul Soumya 3 years ago committed by GitHub
parent 183dcce992
commit 6e21a748b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -287,14 +287,15 @@ impl Keymap {
/// sticky node is in use, it will be cleared. /// sticky node is in use, it will be cleared.
pub fn get(&mut self, key: KeyEvent) -> KeymapResult { pub fn get(&mut self, key: KeyEvent) -> KeymapResult {
if let key!(Esc) = key { if let key!(Esc) = key {
if self.state.is_empty() { if !self.state.is_empty() {
self.sticky = None;
}
return KeymapResult::new( return KeymapResult::new(
// Note that Esc is not included here
KeymapResultKind::Cancelled(self.state.drain(..).collect()), KeymapResultKind::Cancelled(self.state.drain(..).collect()),
self.sticky(), self.sticky(),
); );
} }
self.sticky = None;
}
let first = self.state.get(0).unwrap_or(&key); let first = self.state.get(0).unwrap_or(&key);
let trie_node = match self.sticky { let trie_node = match self.sticky {

Loading…
Cancel
Save