on master help sign in
key is now modified in place at start of handle_event
c1c3750Jan Hrastnik
helix-term/src/ui/editor.rs+5−5
@@ -544,6 +544,7 @@ impl Component for EditorView {
544 EventResult::Consumed(None)
544 EventResult::Consumed(None)
545 }
545 }
546 Event::Key(mut key) => {
546 Event::Key(mut key) => {
547+ canonicalize_key(&mut key);
547 // clear status
548 // clear status
548 cx.editor.status_msg = None;
549 cx.editor.status_msg = None;
549
550
@@ -565,7 +566,7 @@ impl Component for EditorView {
565 match mode {
566 match mode {
566 Mode::Insert => {
567 Mode::Insert => {
567 // record last_insert key
568 // record last_insert key
568− self.last_insert.1.push(canonicalize_key(&mut key));
569+ self.last_insert.1.push(key);
569
570
570 // let completion swallow the event if necessary
571 // let completion swallow the event if necessary
571 let mut consumed = false;
572 let mut consumed = false;
@@ -590,7 +591,7 @@ impl Component for EditorView {
590
591
591 // if completion didn't take the event, we pass it onto commands
592 // if completion didn't take the event, we pass it onto commands
592 if !consumed {
593 if !consumed {
593− self.insert_mode(&mut cxt, canonicalize_key(&mut key));
594+ self.insert_mode(&mut cxt, key);
594
595
595 // lastly we recalculate completion
596 // lastly we recalculate completion
596 if let Some(completion) = &mut self.completion {
597 if let Some(completion) = &mut self.completion {
@@ -601,7 +602,7 @@ impl Component for EditorView {
601 }
602 }
602 }
603 }
603 }
604 }
604− mode => self.command_mode(mode, &mut cxt, canonicalize_key(&mut key)),
605+ mode => self.command_mode(mode, &mut cxt, key),
605 }
606 }
606 }
607 }
607
608
@@ -691,7 +692,7 @@ impl Component for EditorView {
691 }
692 }
692}
693}
693
694
694−fn canonicalize_key(key: &mut KeyEvent) -> KeyEvent {
695+fn canonicalize_key(key: &mut KeyEvent) {
695 if let KeyEvent {
696 if let KeyEvent {
696 code: KeyCode::Char(_),
697 code: KeyCode::Char(_),
697 modifiers: _,
698 modifiers: _,
@@ -699,5 +700,4 @@ fn canonicalize_key(key: &mut KeyEvent) -> KeyEvent {
699 {
700 {
700 key.modifiers.remove(KeyModifiers::SHIFT)
701 key.modifiers.remove(KeyModifiers::SHIFT)
701 }
702 }
702− *key
703}
703}