From e552942ccd8a00fd8c5906c819ef51207f65719e Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Wed, 11 Nov 2015 07:51:49 +0100 Subject: [PATCH] Allow to use numbers as shortcuts, overriding counts ... properly handling the special-case for `0`: - `0J` is _not_ a count, because a count of zero makes no sense. It first invokes the `0` command, and then the `J` command. - `20J` _is_ a count, repeating twenty times. In other words, pressing `2` and then `0` does _not_ run the `0` command (scroll to the far left) with a count of two. Instead, it sets the waiting count to twenty. Fixes #587. --- extension/lib/vimfx.coffee | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extension/lib/vimfx.coffee b/extension/lib/vimfx.coffee index be30347..9b59c6e 100644 --- a/extension/lib/vimfx.coffee +++ b/extension/lib/vimfx.coffee @@ -87,12 +87,8 @@ class VimFx extends utils.EventEmitter command = null switch - when toplevel and DIGIT.test(keyStr) and - not (keyStr == '0' and @count == '') - @count += keyStr - type = 'count' - - when keyStr of @currentKeyTree + when keyStr of @currentKeyTree and + not (keyStr == '0' and @count != '') next = @currentKeyTree[keyStr] if next instanceof Leaf type = 'full' @@ -101,6 +97,11 @@ class VimFx extends utils.EventEmitter @currentKeyTree = next type = 'partial' + when toplevel and DIGIT.test(keyStr) and + not (keyStr == '0' and @count == '') + @count += keyStr + type = 'count' + else @reset(mode) -- 2.39.3