diff options
| author | Stephen Blott | 2015-05-04 11:55:37 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-05-04 11:55:37 +0100 | 
| commit | f9d35083ad511080ee5c01c5c97ef29503f3c0ba (patch) | |
| tree | 76689f25b10f8512f3ac26e3b11057e596ae09c1 /background_scripts | |
| parent | 4e86053f9464c04b9e422625478f8e827f37e533 (diff) | |
| download | vimium-f9d35083ad511080ee5c01c5c97ef29503f3c0ba.tar.bz2 | |
Search completion; simplify/document suggestion options.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 15 | 
1 files changed, 8 insertions, 7 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index b503a452..f09a079c 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -23,6 +23,11 @@ class Suggestion      @title ||= ""      # When @autoSelect is truthy, the suggestion is automatically pre-selected in the vomnibar.      @autoSelect = false +    # If @noHighlightTerms is falsy, then we don't highlight matched terms in the title and URL. +    @autoSelect = true +    # If @insertText is a string, then the indicated text is inserted into the vomnibar input when the +    # suggestion is selected. +    @insertText = null    computeRelevancy: -> @relevancy = @computeRelevancyFunction(this) @@ -345,7 +350,7 @@ class SearchEngineCompleter      if custom        query = queryTerms[1..].join " "        title = if haveDescription then query else keyword + ": " + query -      suggestions.push @mkSuggestion false, queryTerms, type, mkUrl(query), title, @computeRelevancy, 1 +      suggestions.push @mkSuggestion null, queryTerms, type, mkUrl(query), title, @computeRelevancy, 1        suggestions[0].autoSelect = true        queryTerms = queryTerms[1..] @@ -384,17 +389,13 @@ class SearchEngineCompleter          SearchEngines.complete searchUrl, queryTerms, (searchSuggestions = []) =>            for suggestion in searchSuggestions -            suggestions.push @mkSuggestion true, queryTerms, type, mkUrl(suggestion), suggestion, @computeRelevancy, score +            insertText = if custom then "#{keyword} #{suggestion}" else suggestion +            suggestions.push @mkSuggestion insertText, queryTerms, type, mkUrl(suggestion), suggestion, @computeRelevancy, score              score *= 0.9            # Experimental. Force the best match to the top of the list.            suggestions[0].extraRelevancyData = 0.9999999 if 0 < suggestions.length -          if custom -            # For custom search engines, we need to tell the front end to insert the search engine's keyword -            # when copying a suggestion into the vomnibar. -            suggestion.reinsertPrefix = "#{keyword} " for suggestion in suggestions -            # We keep at least three suggestions (if possible) and at most six.  We keep more than three only if            # there are enough slots.  The idea is that these suggestions shouldn't wholly displace suggestions            # from other completers.  That would potentially be a problem because there is no relationship  | 
