aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-06-06 14:19:45 +0100
committerStephen Blott2015-06-06 14:19:51 +0100
commitcb900a255113b8304d8931f7c6294e20f7f9f36d (patch)
treee4c654261cdaeb53220a9d321c641df2ec8c1e2a /background_scripts
parent4eda19de339212f86a9b008a4f3142a61d62829e (diff)
downloadvimium-cb900a255113b8304d8931f7c6294e20f7f9f36d.tar.bz2
Re-work completions: only offer actual search URL matches.
When filter suggestions from other completers, most notably the history completer, we only keep suggestions which match the current searchUrl and completer. Here, we also *replace* the URL of the suggestion. With duplicate elimination, multiple history entries (e.g. those generated with various "Search Tools" settings on Google) will be collapsed to one. This matters because, with custom search engines, we don't show the URL, so the user can't see differences in the URL. Without this, the user can be presented with a list of apparently identical completions.
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