key is now modified in place at start of handle_event

imgbot
Jan Hrastnik 4 years ago committed by Blaž Hrastnik
parent daad8ebe12
commit c1c3750d38

@ -544,6 +544,7 @@ impl Component for EditorView {
EventResult::Consumed(None) EventResult::Consumed(None)
} }
Event::Key(mut key) => { Event::Key(mut key) => {
canonicalize_key(&mut key);
// clear status // clear status
cx.editor.status_msg = None; cx.editor.status_msg = None;
@ -565,7 +566,7 @@ impl Component for EditorView {
match mode { match mode {
Mode::Insert => { Mode::Insert => {
// record last_insert key // 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 completion swallow the event if necessary
let mut consumed = false; 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 completion didn't take the event, we pass it onto commands
if !consumed { if !consumed {
self.insert_mode(&mut cxt, canonicalize_key(&mut key)); self.insert_mode(&mut cxt, key);
// lastly we recalculate completion // lastly we recalculate completion
if let Some(completion) = &mut self.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 { if let KeyEvent {
code: KeyCode::Char(_), code: KeyCode::Char(_),
modifiers: _, modifiers: _,
@ -699,5 +700,4 @@ fn canonicalize_key(key: &mut KeyEvent) -> KeyEvent {
{ {
key.modifiers.remove(KeyModifiers::SHIFT) key.modifiers.remove(KeyModifiers::SHIFT)
} }
*key
} }

Loading…
Cancel
Save