From 356d9a9f67cf925e6c819b41a36c0598f9ab4af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Ad=C3=A0lia?= Date: Wed, 13 Apr 2022 20:38:21 +0200 Subject: [PATCH 1/2] Added ability to remap 0 --- helix-term/src/ui/editor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 459a8c8764e0..0c1bc79ef1cf 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -749,7 +749,12 @@ impl EditorView { fn command_mode(&mut self, mode: Mode, cxt: &mut commands::Context, event: KeyEvent) { match event { // count handling - key!(i @ '0'..='9') => { + key!(i @ '0') if cxt.editor.count.is_some() => { + let i = i.to_digit(10).unwrap() as usize; + cxt.editor.count = + std::num::NonZeroUsize::new(cxt.editor.count.map_or(i, |c| c.get() * 10 + i)); + } + key!(i @ '1'..='9') => { let i = i.to_digit(10).unwrap() as usize; cxt.editor.count = std::num::NonZeroUsize::new(cxt.editor.count.map_or(i, |c| c.get() * 10 + i)); From 0f5dd6c88bf2fbf6f80b6d3d8120611d4f5d126a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Ad=C3=A0lia?= Date: Tue, 19 Apr 2022 15:44:11 +0200 Subject: [PATCH 2/2] Removed duplicated match body --- helix-term/src/ui/editor.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 0c1bc79ef1cf..81799fccbfcc 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -747,20 +747,15 @@ impl EditorView { } fn command_mode(&mut self, mode: Mode, cxt: &mut commands::Context, event: KeyEvent) { - match event { + match (event, cxt.editor.count) { // count handling - key!(i @ '0') if cxt.editor.count.is_some() => { - let i = i.to_digit(10).unwrap() as usize; - cxt.editor.count = - std::num::NonZeroUsize::new(cxt.editor.count.map_or(i, |c| c.get() * 10 + i)); - } - key!(i @ '1'..='9') => { + (key!(i @ '0'), Some(_)) | (key!(i @ '1'..='9'), _) => { let i = i.to_digit(10).unwrap() as usize; cxt.editor.count = std::num::NonZeroUsize::new(cxt.editor.count.map_or(i, |c| c.get() * 10 + i)); } // special handling for repeat operator - key!('.') if self.keymaps.pending().is_empty() => { + (key!('.'), _) if self.keymaps.pending().is_empty() => { // first execute whatever put us into insert mode self.last_insert.0.execute(cxt); // then replay the inputs