diff options
| author | Stephen Blott | 2014-11-18 16:19:13 +0000 |
|---|---|---|
| committer | Stephen Blott | 2014-11-18 16:19:13 +0000 |
| commit | 4c2be63d8591d8b254eed918cebf9fb36e9b5597 (patch) | |
| tree | d17f70ed3e4e8b45e1d23d4ff49abfd14802cebd /background_scripts | |
| parent | 0ba67535c30c601d9f9d2a4158c3637132a976ce (diff) | |
| download | vimium-4c2be63d8591d8b254eed918cebf9fb36e9b5597.tar.bz2 | |
Tab recency; register visit only after 750ms.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index b411bcba..d750850f 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -259,7 +259,8 @@ class DomainCompleter # Suggestions from the Domain completer have the maximum relevancy. They should be shown first in the list. computeRelevancy: -> 1 -# TabRecency associates a logical timestamp with each tab id. +# TabRecency associates a logical timestamp with each tab id. These are used to provide an initial +# recency-based ordering in the tabs vomnibar (which allows jumping quickly between recently-visited tabs). class TabRecency constructor: -> @timestamp = 1 @@ -272,9 +273,20 @@ class TabRecency @remove removedTabId @add addedTabId - add: (tabId) -> @cache[tabId] = ++@timestamp + add: (tabId) -> @soon => @cache[tabId] = ++@timestamp remove: (tabId) -> delete @cache[tabId] + # Call callback in 750ms time; unless we're pre-empted by another call before then. The idea is that tabs + # which are visited only for a very-short time (e.g. with `3J`) shouldn't register as visited at all. + soon: do -> + timer = null + (callback) -> + clearTimeout timer if timer + timer = setTimeout (-> + timer = null + callback()) + , 750 + # Recently-visited tabs get a higher score (except the current tab, which gets a low score). recencyScore: (tabId) -> @cache[tabId] ||= 1 |
