diff options
| author | Stephen Blott | 2015-06-06 20:19:33 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-06-06 20:19:33 +0100 | 
| commit | 616261ef8364cbd99765d651dfe8acd5ff55b453 (patch) | |
| tree | c7b75f7aa9a960132ba484935a4c1ed1cfb63a29 /background_scripts/completion.coffee | |
| parent | c20e5d44455be8ac885f0d7c42e05ec9857bd203 (diff) | |
| parent | cb900a255113b8304d8931f7c6294e20f7f9f36d (diff) | |
| download | vimium-616261ef8364cbd99765d651dfe8acd5ff55b453.tar.bz2 | |
Merge branch 'rework-completions'
Conflicts:
	background_scripts/completion.coffee
	background_scripts/completion_engines.coffee
Diffstat (limited to 'background_scripts/completion.coffee')
| -rw-r--r-- | background_scripts/completion.coffee | 29 | 
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  | 
