From 1de41f55c121192556a7bf182211fb3b6deeccc8 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 21 Feb 2016 07:32:20 +0000 Subject: Include count command option in repeat limit. We need to multiply by `count=N` *before* checking `repeatLimit`. Tweaks #2001. --- background_scripts/commands.coffee | 5 +++-- background_scripts/main.coffee | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index b4c503c1..74c2d08b 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -84,8 +84,9 @@ Commands = options[parse[0]] = if parse.length == 1 then true else parse[1] # We parse any `count` option immediately (to avoid having to parse it repeatedly later). - if "count" of options and not @availableCommands[command].noRepeat - options.count = if /^[1-9]/.test options.count then parseInt options.count else 1 + if "count" of options + options.count = parseInt options.count + delete options.count if isNaN(options.count) or @availableCommands[command].noRepeat options diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 196cf11f..a4162fc7 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -470,6 +470,7 @@ checkKeyQueue = (keysToCheck, tabId, frameId) -> if (Commands.keyToCommandRegistry[command]) registryEntry = Commands.keyToCommandRegistry[command] runCommand = true + count *= registryEntry.options.count ? 1 if registryEntry.noRepeat count = 1 @@ -482,8 +483,6 @@ checkKeyQueue = (keysToCheck, tabId, frameId) -> """ if runCommand - # Account for any command-option "count". - count *= registryEntry.options.count ? 1 if not registryEntry.isBackgroundCommand chrome.tabs.sendMessage tabId, name: "executePageCommand" -- cgit v1.2.3