From c1c3750d3801558bb9e6722e67d724b480a4cffa Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Thu, 3 Jun 2021 15:26:24 +0200 Subject: [PATCH] key is now modified in place at start of handle_event --- helix-term/src/ui/editor.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index da95763ed..b1c4ce3fe 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -544,6 +544,7 @@ impl Component for EditorView { EventResult::Consumed(None) } Event::Key(mut key) => { + canonicalize_key(&mut key); // clear status cx.editor.status_msg = None; @@ -565,7 +566,7 @@ impl Component for EditorView { match mode { Mode::Insert => { // record last_insert key - self.last_insert.1.push(canonicalize_key(&mut key)); + self.last_insert.1.push(key); // let completion swallow the event if necessary let mut consumed = false; @@ -590,7 +591,7 @@ impl Component for EditorView { // if completion didn't take the event, we pass it onto commands if !consumed { - self.insert_mode(&mut cxt, canonicalize_key(&mut key)); + self.insert_mode(&mut cxt, key); // lastly we recalculate completion if let Some(completion) = &mut self.completion { @@ -601,7 +602,7 @@ impl Component for EditorView { } } } - mode => self.command_mode(mode, &mut cxt, canonicalize_key(&mut key)), + mode => self.command_mode(mode, &mut cxt, key), } } @@ -691,7 +692,7 @@ impl Component for EditorView { } } -fn canonicalize_key(key: &mut KeyEvent) -> KeyEvent { +fn canonicalize_key(key: &mut KeyEvent) { if let KeyEvent { code: KeyCode::Char(_), modifiers: _, @@ -699,5 +700,4 @@ fn canonicalize_key(key: &mut KeyEvent) -> KeyEvent { { key.modifiers.remove(KeyModifiers::SHIFT) } - *key }