aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts/completion.coffee')
-rw-r--r--background_scripts/completion.coffee29
1 files changed, 16 insertions, 13 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index cbc5e698..189929b4 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -454,29 +454,32 @@ class SearchEngineCompleter
{ keyword, searchUrl, description } = engine
extend request, searchUrl, customSearchMode: true
- factor = 0.5
+ @previousSuggestions[searchUrl] ?= []
haveCompletionEngine = CompletionSearch.haveCompletionEngine searchUrl
# This filter is applied to all of the suggestions from all of the completers, after they have been
# aggregated by the MultiCompleter.
filter = (suggestions) ->
- suggestions.filter (suggestion) ->
- # We only keep suggestions which either *were* generated by this search engine, or *could have
- # been* generated by this search engine (and match the current query).
- suggestion.searchUrl == searchUrl or
- (
- terms = Utils.extractQuery searchUrl, suggestion.url
- terms and RankingUtils.matches queryTerms, terms
- )
+ # We only keep suggestions which either *were* generated by this search engine, or *could have
+ # been* generated by this search engine (and match the current query).
+ for suggestion in suggestions
+ if suggestion.isSearchSuggestion or suggestion.isCustomSearch
+ suggestion
+ else
+ terms = Utils.extractQuery searchUrl, suggestion.url
+ continue unless terms and RankingUtils.matches queryTerms, terms
+ suggestion.url = Utils.createSearchUrl terms, searchUrl
+ suggestion
# If a previous suggestion still matches the query, then we keep it (even if the completion engine may not
- # return it for the current query). This allows the user to pick suggestions by typing fragments of their
- # text, without regard to whether the completion engine can complete the actual text of the query.
+ # return it for the current query). This allows the user to pick suggestions that they've previously seen
+ # by typing fragments of their text, without regard to whether the completion engine can continue to
+ # complete the actual text of the query.
previousSuggestions =
if queryTerms.length == 0
[]
else
- for url, suggestion of @previousSuggestions
+ for _, suggestion of @previousSuggestions[searchUrl]
continue unless RankingUtils.matches queryTerms, suggestion.title
# Reset various fields, they may not be correct wrt. the current query.
extend suggestion, relevancy: null, html: null, queryTerms: queryTerms
@@ -501,7 +504,7 @@ class SearchEngineCompleter
count = 0
(suggestion) =>
url = Utils.createSearchUrl suggestion, searchUrl
- @previousSuggestions[url] = new Suggestion
+ @previousSuggestions[searchUrl][url] = new Suggestion
queryTerms: queryTerms
type: description
url: url