diff options
| author | Phil Crosby | 2014-05-13 09:59:26 -0700 |
|---|---|---|
| committer | Phil Crosby | 2014-05-13 09:59:26 -0700 |
| commit | 11a0bdd69140ab94673fc42bd7b7fd0e9fdeaa8c (patch) | |
| tree | 0ffecdabcddd799f316a1fa3e68b3295eae157b7 | |
| parent | 9fdd122abde7c55926b6d58e135f1bcb3024c0a2 (diff) | |
| parent | 3e734271ce45cdfd0235057b7a3c2f19e523a9c4 (diff) | |
| download | vimium-11a0bdd69140ab94673fc42bd7b7fd0e9fdeaa8c.tar.bz2 | |
Merge pull request #1057 from mrmr1993/moveTabs
Fix implementation of and add repetition to moveTabLeft and moveTabRight commands
| -rw-r--r-- | background_scripts/main.coffee | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 666c37e0..0511303a 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -219,7 +219,9 @@ repeatFunction = (func, totalCount, currentCount, frameId) -> moveTab = (callback, direction) -> chrome.tabs.getSelected(null, (tab) -> - chrome.tabs.move(tab.id, {index: tab.index + direction }, callback)) + # 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)) # Start action functions @@ -238,8 +240,6 @@ BackgroundCommands = previousTab: (callback) -> selectTab(callback, "previous") firstTab: (callback) -> selectTab(callback, "first") lastTab: (callback) -> selectTab(callback, "last") - moveTabLeft: (callback) -> moveTab(callback, -1) - moveTabRight: (callback) -> moveTab(callback, 1) removeTab: -> chrome.tabs.getSelected(null, (tab) -> chrome.tabs.remove(tab.id)) @@ -275,6 +275,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) nextFrame: (count) -> chrome.tabs.getSelected(null, (tab) -> frames = framesForTab[tab.id].frames |
