diff options
| author | Stephen Blott | 2015-05-18 08:10:48 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-18 08:11:01 +0100 |
| commit | b7f94dbcaea5c2bb944dfeaf6f929629834af723 (patch) | |
| tree | 371d989624e25700a08cf5501149571d65e9a78a /background_scripts | |
| parent | 8e888bf0277f9b7af1ab1bacd0b1a2481e57599a (diff) | |
| download | vimium-b7f94dbcaea5c2bb944dfeaf6f929629834af723.tar.bz2 | |
Search completion; retain previous (matching) suggestions.
This address "UX Issue 2" from #1651.
If the user types "w lake vict" and sees a suggestion "lake victoria
perch", and continues "w lake vict pe", then we retain the previous
suggestion (which still matches) despite the fact that the completion no
longer delivers it.
This creates a more consistent, Vimium-like vomnibar UX.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 9177298e..8768a39f 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -396,6 +396,7 @@ class TabCompleter class SearchEngineCompleter @debug: false searchEngines: null + previousSuggestions: null cancel: -> CompletionSearch.cancel() @@ -415,6 +416,7 @@ class SearchEngineCompleter engine: engines[keyword] refresh: (port) -> + @previousSuggestions = {} # Parse the search-engine configuration. @searchEngines = new AsyncDataFetcher (callback) -> engines = {} @@ -478,6 +480,12 @@ class SearchEngineCompleter # And the URL suffix (which must contain the query part) matches the current query. RankingUtils.matches queryTerms, suggestion.url[engine.searchUrlPrefix.length..]) + previousSuggestions = + for url, suggestion of @previousSuggestions + continue unless RankingUtils.matches queryTerms, suggestion.title + suggestion.relevancy = null + suggestion + primarySuggestion = new Suggestion queryTerms: queryTerms type: description @@ -491,7 +499,8 @@ class SearchEngineCompleter mkSuggestion = do => count = 0 (suggestion) => - new Suggestion + url = Utils.createSearchUrl suggestion, searchUrl + @previousSuggestions[url] = new Suggestion queryTerms: queryTerms type: description url: Utils.createSearchUrl suggestion, searchUrl @@ -508,7 +517,7 @@ class SearchEngineCompleter cachedSuggestions = if haveCompletionEngine then CompletionSearch.complete searchUrl, queryTerms else null - suggestions = [] + suggestions = previousSuggestions suggestions.push primarySuggestion if custom suggestions.push cachedSuggestions.map(mkSuggestion)... if custom and cachedSuggestions? |
