aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/bg_utils.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-02-10 06:26:55 +0000
committerStephen Blott2016-02-10 06:26:55 +0000
commit1d809afe18d8638b899a1016d9cca0ccc4a32253 (patch)
treef704f73fd00b0e0b323cefbda45f06f8bd55f8c6 /background_scripts/bg_utils.coffee
parent60d33d20026cdcdd0c4ecef20410d38341c86633 (diff)
downloadvimium-1d809afe18d8638b899a1016d9cca0ccc4a32253.tar.bz2
BgUtils; two fixes...
- handle case where there's only one tab - also focus the selected tab's window
Diffstat (limited to 'background_scripts/bg_utils.coffee')
-rw-r--r--background_scripts/bg_utils.coffee9
1 files changed, 4 insertions, 5 deletions
diff --git a/background_scripts/bg_utils.coffee b/background_scripts/bg_utils.coffee
index bd00fd24..96c1282a 100644
--- a/background_scripts/bg_utils.coffee
+++ b/background_scripts/bg_utils.coffee
@@ -39,12 +39,11 @@ class TabRecency
@cache[tabId] ||= 1
if tabId == @current then 0.0 else @cache[tabId] / @timestamp
- # Get the tab Id of the count-th most recently visited tab (excluding tabId, which is the current tab).
- getRecentTab: (tabId, count) ->
- tabId = tabId.toString()
- tabIds = (tId for own tId of @cache when tId != tabId)
+ # Returns a list of tab Ids sorted by recency, most recent tab first.
+ getTabsByRecency: ->
+ tabIds = (tId for own tId of @cache)
tabIds.sort (a,b) => @cache[b] - @cache[a]
- parseInt tabIds[(count-1)%tabIds.length]
+ tabIds.map (tId) -> parseInt tId
BgUtils =
tabRecency: new TabRecency()