aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authormrmr19932014-05-13 16:38:46 +0100
committermrmr19932014-05-13 16:38:58 +0100
commit3e734271ce45cdfd0235057b7a3c2f19e523a9c4 (patch)
tree0ffecdabcddd799f316a1fa3e68b3295eae157b7 /background_scripts
parent9fdd122abde7c55926b6d58e135f1bcb3024c0a2 (diff)
downloadvimium-3e734271ce45cdfd0235057b7a3c2f19e523a9c4.tar.bz2
Fix implementation of and add repetition to moveTabLeft and moveTabRight commands
This fixes #1056.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee8
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