From 69cd8c08375cdf5df8636748f6f479552d780b8f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 17 May 2015 06:11:45 +0100 Subject: TabToOpen: tab to open vomnibar. `o` then `Tab` opens the vomnibar completionlist with history completions (the only completions) ranked by recently only. Hence, the most recent requests are at the top. This is a (far) simpler approach than #1662 which catches the most important use case (repeat a search with an edited query). --- background_scripts/completion.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index eb80f3cd..80b47055 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -225,7 +225,7 @@ class BookmarkCompleter RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title) class HistoryCompleter - filter: ({ queryTerms }, onComplete) -> + filter: ({ queryTerms, tabToOpen }, onComplete) -> @currentSearch = { queryTerms: @queryTerms, onComplete: @onComplete } results = [] HistoryCache.use (history) => @@ -233,6 +233,9 @@ class HistoryCompleter results = if queryTerms.length > 0 history.filter (entry) -> RankingUtils.matches(queryTerms, entry.url, entry.title) + else if tabToOpen + # opens the completion list, even without a query. + history else [] onComplete results.map (entry) => @@ -256,6 +259,8 @@ class HistoryCompleter computeRelevancy: (suggestion) -> historyEntry = suggestion.relevancyData recencyScore = RankingUtils.recencyScore(historyEntry.lastVisitTime) + # If there are no query terms, then relevancy is based on recency alone. + return recencyScore if suggestion.queryTerms.length == 0 wordRelevancy = RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title) if suggestion.insertText? # If this suggestion matches a previous search with the default search engine, then we also score the -- cgit v1.2.3