aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/completion.coffee26
1 files changed, 14 insertions, 12 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 6b58f4ea..fc6263ee 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -456,24 +456,26 @@ class SearchEngineCompleter
# 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.isSearchSuggestion or suggestion.isCustomSearch 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 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.
+ # 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[searchUrl]
+ 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