on master help sign in
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.

commit6e21a748b87a4eb9381ea0d24117711c5b547ab1 authorGokul Soumya <gokulps15@gmail.com> dateSun 5 Sep 2021, 17:50 (5 years ago) parent183dcce
1 file changed+7−6
helix-term/src/keymap.rs+7−6
helix-term/src/keymap.rs+7−6
@@ -287,13 +287,14 @@ impl Keymap {
287287 /// sticky node is in use, it will be cleared.
288288 pub fn get(&mut self, key: KeyEvent) -> KeymapResult {
289289 if let key!(Esc) = key {
290− if self.state.is_empty() {
291− self.sticky = None;
290+ if !self.state.is_empty() {
291+ return KeymapResult::new(
292+ // Note that Esc is not included here
293+ KeymapResultKind::Cancelled(self.state.drain(..).collect()),
294+ self.sticky(),
295+ );
292296 }
293− return KeymapResult::new(
294− KeymapResultKind::Cancelled(self.state.drain(..).collect()),
295− self.sticky(),
296− );
297+ self.sticky = None;
297298 }
298299
299300 let first = self.state.get(0).unwrap_or(&key);