diff options
| author | Stephen Blott | 2015-05-04 11:42:59 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-04 11:43:02 +0100 |
| commit | 4e86053f9464c04b9e422625478f8e827f37e533 (patch) | |
| tree | 9a338c239156807bf140878ac4db3edc521897d3 | |
| parent | b2ae01c8604ed87f52afa3b5e769fb340dcb1b93 (diff) | |
| download | vimium-4e86053f9464c04b9e422625478f8e827f37e533.tar.bz2 | |
Search completion; do not highlight search terms.
Highlighting the search terms suggests they are in some way contributing
to the match. They are not, so don't highlight them.
This gets particularly ugly when you have short, single-letter costom
search engines (eg. w), and have all of the "w"s highlighted -- for not
useful reason.
| -rw-r--r-- | background_scripts/completion.coffee | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 795b4658..b503a452 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -29,15 +29,17 @@ class Suggestion generateHtml: -> return @html if @html relevancyHtml = if @showRelevancy then "<span class='relevancy'>#{@computeRelevancy()}</span>" else "" + highlightTerms = + if @noHighlightTerms then ((s) -> Utils.escapeHtml s) else ((s) => @highlightTerms Utils.escapeHtml s) # NOTE(philc): We're using these vimium-specific class names so we don't collide with the page's CSS. @html = """ <div class="vimiumReset vomnibarTopHalf"> <span class="vimiumReset vomnibarSource">#{@type}</span> - <span class="vimiumReset vomnibarTitle">#{@highlightTerms(Utils.escapeHtml(@title))}</span> + <span class="vimiumReset vomnibarTitle">#{highlightTerms @title}</span> </div> <div class="vimiumReset vomnibarBottomHalf"> - <span class="vimiumReset vomnibarUrl">#{@shortenUrl(@highlightTerms(Utils.escapeHtml(@url)))}</span> + <span class="vimiumReset vomnibarUrl">#{@shortenUrl highlightTerms @url}</span> #{relevancyHtml} </div> """ @@ -402,8 +404,7 @@ class SearchEngineCompleter mkSuggestion: (insertText, args...) -> suggestion = new Suggestion args... - suggestion.insertText = insertText - suggestion + extend suggestion, insertText: insertText, noHighlightTerms: true # The score is computed in filter() and provided here via suggestion.extraRelevancyData. computeRelevancy: (suggestion) -> suggestion.extraRelevancyData |
