aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/main.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts/main.coffee')
-rw-r--r--background_scripts/main.coffee15
1 files changed, 7 insertions, 8 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 1a49c3cb..10f7500e 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -267,8 +267,8 @@ BackgroundCommands =
chrome.windows.create {tabId: tab.id, incognito: tab.incognito}
nextTab: (count) -> selectTab "next", count
previousTab: (count) -> selectTab "previous", count
- firstTab: -> selectTab "first"
- lastTab: -> selectTab "last"
+ firstTab: (count) -> selectTab "first", count
+ lastTab: (count) -> selectTab "last", count
removeTab: (callback) ->
chrome.tabs.getSelected(null, (tab) ->
chrome.tabs.remove(tab.id)
@@ -349,15 +349,13 @@ selectTab = (direction, count = 1) ->
toSelect =
switch direction
when "next"
- currentTab.index + count
+ (currentTab.index + count) % tabs.length
when "previous"
- currentTab.index - count
+ (currentTab.index - count + count * tabs.length) % tabs.length
when "first"
- 0
+ Math.min tabs.length - 1, count - 1
when "last"
- tabs.length - 1
- # Bring toSelect into the range [0,tabs.length).
- toSelect = (toSelect + tabs.length * Math.abs count) % tabs.length
+ Math.max 0, tabs.length - count
chrome.tabs.update tabs[toSelect].id, selected: true
updateOpenTabs = (tab, deleteFrames = false) ->
@@ -670,6 +668,7 @@ sendRequestHandlers =
setIcon: setIcon
sendMessageToFrames: sendMessageToFrames
log: bgLog
+ fetchFileContents: (request, sender) -> fetchFileContents request.fileName
# We always remove chrome.storage.local/findModeRawQueryListIncognito on startup.
chrome.storage.local.remove "findModeRawQueryListIncognito"