aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hrastnik2021-06-03 10:14:02 +0000
committerBlaž Hrastnik2021-06-03 14:16:04 +0000
commit68abc67ec6846ab4d05b0e46d1baa65dc026e7dd (patch)
tree840a3e341f5bdc9ddc8dc719ae037436c51ac0c5
parent712f25c2b952672d496d393552d1545d54de3d51 (diff)
put the key canonicalization in a seperate function. only chars now get stripped of Shift modifier
-rw-r--r--helix-term/src/ui/editor.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 19db3fa7..0b0ad5ed 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -547,11 +547,6 @@ impl Component for EditorView {
// clear status
cx.editor.status_msg = None;
- //canonicalize the key
- if key.modifiers == KeyModifiers::SHIFT {
- key.modifiers = KeyModifiers::NONE;
- }
-
let (view, doc) = cx.editor.current();
let mode = doc.mode();
@@ -570,7 +565,7 @@ impl Component for EditorView {
match mode {
Mode::Insert => {
// record last_insert key
- self.last_insert.1.push(key);
+ self.last_insert.1.push(canonicalize_key(&mut key));
// let completion swallow the event if necessary
let mut consumed = false;
@@ -595,7 +590,7 @@ impl Component for EditorView {
// if completion didn't take the event, we pass it onto commands
if !consumed {
- self.insert_mode(&mut cxt, key);
+ self.insert_mode(&mut cxt, canonicalize_key(&mut key));
// lastly we recalculate completion
if let Some(completion) = &mut self.completion {
@@ -606,7 +601,7 @@ impl Component for EditorView {
}
}
}
- mode => self.command_mode(mode, &mut cxt, key),
+ mode => self.command_mode(mode, &mut cxt, canonicalize_key(&mut key)),
}
}
@@ -695,3 +690,10 @@ impl Component for EditorView {
None
}
}
+
+fn canonicalize_key(key: &mut KeyEvent) -> KeyEvent {
+ if let KeyEvent { code: KeyCode::Char(_), modifiers: KeyModifiers::SHIFT } = key {
+ key.modifiers = KeyModifiers::NONE;
+ }
+ *key
+} \ No newline at end of file