From b83165dd1f279c2b139401bd9efc075bc89cf060 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 24 Nov 2014 06:00:44 +0000 Subject: Frames; eliminate Array::rotate (and support large counts). --- background_scripts/main.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'background_scripts/main.coffee') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 48b54492..3ec618c9 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -284,10 +284,10 @@ BackgroundCommands = moveTabRight: (count) -> moveTab(null, count) nextFrame: (count,frameId) -> chrome.tabs.getSelected(null, (tab) -> + frames = frameIdsForTab[tab.id] # 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. - count += Math.max 0, frameIdsForTab[tab.id].indexOf frameId - frames = frameIdsForTab[tab.id] + count = (count + Math.max 0, frameIdsForTab[tab.id].indexOf frameId) % frames.length frames = frameIdsForTab[tab.id] = [frames[count..]..., frames[0...count]...] chrome.tabs.sendMessage(tab.id, { name: "focusFrame", frameId: frames[0], highlight: true })) -- cgit v1.2.3