Skip to content

Commit

Permalink
key is now modified in place at start of handle_event
Browse files Browse the repository at this point in the history
  • Loading branch information
janhrastnik authored and archseer committed Jun 3, 2021
1 parent daad8eb commit c1c3750
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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),
}
}

Expand Down Expand Up @@ -691,13 +692,12 @@ impl Component for EditorView {
}
}

fn canonicalize_key(key: &mut KeyEvent) -> KeyEvent {
fn canonicalize_key(key: &mut KeyEvent) {
if let KeyEvent {
code: KeyCode::Char(_),
modifiers: _,
} = key
{
key.modifiers.remove(KeyModifiers::SHIFT)
}
*key
}

0 comments on commit c1c3750

Please sign in to comment.