diff options
| author | Stephen Blott | 2015-06-25 05:09:36 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-06-25 05:09:36 +0100 |
| commit | e5faeff7d48a206a080a56a6541963d2d3c86da7 (patch) | |
| tree | 751d29c6c499bf1325a20539b171829586a9b706 /background_scripts | |
| parent | 39e10495709eeafd972a8b66ee741bf25deee7e5 (diff) | |
| parent | aa08e16e6613d5a3760761ab89557df41a50f784 (diff) | |
| download | vimium-e5faeff7d48a206a080a56a6541963d2d3c86da7.tar.bz2 | |
Merge branch 'store-all-settings' into hud-iframe-input-with-store-all-settings
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 835b8a9a..d4b14f3c 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -237,11 +237,12 @@ repeatFunction = (func, totalCount, currentCount, frameId) -> -> repeatFunction(func, totalCount, currentCount + 1, frameId), frameId) -moveTab = (callback, direction) -> - chrome.tabs.getSelected(null, (tab) -> - # Use Math.max to prevent -1 as the new index, otherwise the tab of index n will wrap to the far RHS when - # moved left by exactly (n+1) places. - chrome.tabs.move(tab.id, {index: Math.max(0, tab.index + direction) }, callback)) +moveTab = (count) -> + chrome.tabs.getAllInWindow null, (tabs) -> + pinnedCount = (tabs.filter (tab) -> tab.pinned).length + chrome.tabs.getSelected null, (tab) -> + chrome.tabs.move tab.id, + index: Math.max pinnedCount, Math.min tabs.length - 1, tab.index + count # Start action functions @@ -304,8 +305,8 @@ BackgroundCommands = chrome.tabs.getSelected(null, (tab) -> chrome.tabs.sendMessage(tab.id, { name: "toggleHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId })) - moveTabLeft: (count) -> moveTab(null, -count) - moveTabRight: (count) -> moveTab(null, count) + moveTabLeft: (count) -> moveTab -count + moveTabRight: (count) -> moveTab count nextFrame: (count,frameId) -> chrome.tabs.getSelected null, (tab) -> frameIdsForTab[tab.id] = cycleToFrame frameIdsForTab[tab.id], frameId, count |
