diff options
Diffstat (limited to 'background_scripts/main.coffee')
| -rw-r--r-- | background_scripts/main.coffee | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 14ce7b0f..898f46f1 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -244,9 +244,10 @@ BackgroundCommands = previousTab: (callback) -> selectTab(callback, "previous") firstTab: (callback) -> selectTab(callback, "first") lastTab: (callback) -> selectTab(callback, "last") - removeTab: -> + removeTab: (callback) -> chrome.tabs.getSelected(null, (tab) -> - chrome.tabs.remove(tab.id)) + chrome.tabs.remove(tab.id) + selectionChangedHandlers.push(callback)) restoreTab: (callback) -> # TODO: remove if-else -block when adopted into stable if chrome.sessions @@ -530,23 +531,35 @@ checkKeyQueue = (keysToCheck, tabId, frameId) -> if (Commands.keyToCommandRegistry[command]) registryEntry = Commands.keyToCommandRegistry[command] - - if !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]() + runCommand = true + + if registryEntry.noRepeat + count = 1 + else if registryEntry.repeatLimit and count > registryEntry.repeatLimit + runCommand = confirm """ + You have asked Vimium to perform #{count} repeats of the command: + #{Commands.availableCommands[registryEntry.command].description} + + Are you sure you want to continue? + """ + + 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) |
