Skip to content

Commit

Permalink
Limit repeats, minor refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
smblott-github committed Oct 26, 2014
1 parent 3340694 commit d222439
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions background_scripts/commands.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ defaultKeyMappings =


# This is a mapping of: commandIdentifier => [description, options].
# If the noRepeat and repeatLimit options are both specified, then noRepeat takes precedence.
commandDescriptions =
# Navigating the current page
showHelp: ["Show help", { background: true }]
Expand Down
34 changes: 16 additions & 18 deletions background_scripts/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ checkKeyQueue = (keysToCheck, tabId, frameId) ->

if (Commands.keyToCommandRegistry[command])
registryEntry = Commands.keyToCommandRegistry[command]

runCommand = true

if registryEntry.noRepeat
Expand All @@ -544,24 +543,23 @@ checkKeyQueue = (keysToCheck, tabId, frameId) ->
Are you sure you want to continue?
"""

if not runCommand
# Do nothing, use has chosen not to execute the command
else if not registryEntry.isBackgroundCommand
chrome.tabs.sendMessage(tabId,
name: "executePageCommand",
command: registryEntry.command,
frameId: frameId,
count: count,
passCountToFunction: registryEntry.passCountToFunction,
completionKeys: generateCompletionKeys(""))
refreshedCompletionKeys = true
else
if registryEntry.passCountToFunction
BackgroundCommands[registryEntry.command](count)
else if registryEntry.noRepeat
BackgroundCommands[registryEntry.command]()
if runCommand
if not registryEntry.isBackgroundCommand
chrome.tabs.sendMessage(tabId,
name: "executePageCommand",
command: registryEntry.command,
frameId: frameId,
count: count,
passCountToFunction: registryEntry.passCountToFunction,
completionKeys: generateCompletionKeys(""))
refreshedCompletionKeys = true
else
repeatFunction(BackgroundCommands[registryEntry.command], count, 0, frameId)
if registryEntry.passCountToFunction
BackgroundCommands[registryEntry.command](count)
else if registryEntry.noRepeat
BackgroundCommands[registryEntry.command]()
else
repeatFunction(BackgroundCommands[registryEntry.command], count, 0, frameId)

newKeyQueue = ""
else if (getActualKeyStrokeLength(command) > 1)
Expand Down

0 comments on commit d222439

Please sign in to comment.