From 76d3e7bc391542655c6a4ac25ef44c75aa1f0b12 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 23 Nov 2014 15:49:00 +0000 Subject: Frames; always start rotation from the current frame. --- background_scripts/main.coffee | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index e8a57fd5..27800ce6 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -282,9 +282,12 @@ BackgroundCommands = { name: "toggleHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId })) moveTabLeft: (count) -> moveTab(null, -count) moveTabRight: (count) -> moveTab(null, count) - nextFrame: (count) -> + nextFrame: (count,frameId) -> chrome.tabs.getSelected(null, (tab) -> - frames = frameIdsForTab[tab.id] = frameIdsForTab[tab.id].rotate(count) + # We can't always track which frame chrome has focussed, but here we learn that it's frameId; so add an + # additional offset such that we do indeed start from frameId. + offset = Math.max 0, frameIdsForTab[tab.id].indexOf frameId + frames = frameIdsForTab[tab.id] = frameIdsForTab[tab.id].rotate(count+offset) chrome.tabs.sendMessage(tab.id, { name: "focusFrame", frameId: frames[0], highlight: true })) closeTabsOnLeft: -> removeTabsRelative "before" @@ -548,9 +551,9 @@ checkKeyQueue = (keysToCheck, tabId, frameId) -> refreshedCompletionKeys = true else if registryEntry.passCountToFunction - BackgroundCommands[registryEntry.command](count) + BackgroundCommands[registryEntry.command](count, frameId) else if registryEntry.noRepeat - BackgroundCommands[registryEntry.command]() + BackgroundCommands[registryEntry.command](frameId) else repeatFunction(BackgroundCommands[registryEntry.command], count, 0, frameId) -- cgit v1.2.3