summaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorMichael Davis2024-03-15 23:52:57 +0000
committerGitHub2024-03-15 23:52:57 +0000
commit9282f1b8e546583d9e461cd78bed7d2f21dd1770 (patch)
treed9ff6b3bf6df7fa9204a9f5adf05d7ce9d6628ef /helix-term
parentb961acf74601f0ede754d595f52ed4cba300e37f (diff)
Handle starting and continuing the count separately (#9887)
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index f3bba5d1..c1e36bbd 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -916,13 +916,15 @@ impl EditorView {
fn command_mode(&mut self, mode: Mode, cxt: &mut commands::Context, event: KeyEvent) {
match (event, cxt.editor.count) {
- // count handling
- (key!(i @ '0'), Some(_)) | (key!(i @ '1'..='9'), _)
- if !self.keymaps.contains_key(mode, event) =>
- {
+ // If the count is already started and the input is a number, always continue the count.
+ (key!(i @ '0'..='9'), Some(count)) => {
+ let i = i.to_digit(10).unwrap() as usize;
+ cxt.editor.count = NonZeroUsize::new(count.get() * 10 + i);
+ }
+ // A non-zero digit will start the count if that number isn't used by a keymap.
+ (key!(i @ '1'..='9'), None) if !self.keymaps.contains_key(mode, event) => {
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));
+ cxt.editor.count = NonZeroUsize::new(i);
}
// special handling for repeat operator
(key!('.'), _) if self.keymaps.pending().is_empty() => {