aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/commands.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-02-20 09:44:57 +0000
committerStephen Blott2016-02-20 09:44:57 +0000
commit2c634d9b2324c760007d59d5cafd97a364125991 (patch)
tree5b48b3ea52ef21124b29d0904f202d8ecbe6f917 /background_scripts/commands.coffee
parent61ce82be4acae20562bb2ccb93ff64772ba553c1 (diff)
downloadvimium-2c634d9b2324c760007d59d5cafd97a364125991.tar.bz2
Add `count` command option.
Examples: map j scrollDown count=10 map q removeTab count=999
Diffstat (limited to 'background_scripts/commands.coffee')
-rw-r--r--background_scripts/commands.coffee9
1 files changed, 7 insertions, 2 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index 47eb7e8e..8d73c913 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -56,7 +56,7 @@ Commands =
if command? and @availableCommands[command]
key = @normalizeKey key
logMessage? "Mapping #{key} to #{command}"
- @mapKeyToCommand { key, command, options: @parseCommandOptions optionList }
+ @mapKeyToCommand { key, command, options: @parseCommandOptions command, optionList }
when "unmap"
if tokens.length == 2
@@ -77,7 +77,7 @@ Commands =
# Command options follow command mappings, and are of one of two forms:
# key=value - a value
# key - a flag
- parseCommandOptions: (optionList) ->
+ parseCommandOptions: (command, optionList) ->
options = {}
for option in optionList
parse = option.split "="
@@ -88,6 +88,11 @@ Commands =
options[parse[0]] = parse[1]
else
console.log "Vimium configuration error: invalid option: #{option}."
+
+ # We parse any `count` option immediately (to avoid having to parse it repeatedly later).
+ unless @availableCommands[command].noRepeat
+ options.count = try Math.max 1, parseInt options.count
+
options
clearKeyMappingsAndSetDefaults: ->