From 4e86053f9464c04b9e422625478f8e827f37e533 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 4 May 2015 11:42:59 +0100 Subject: 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. --- background_scripts/completion.coffee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'background_scripts') 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 "#{@computeRelevancy()}" 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 = """
#{@type} - #{@highlightTerms(Utils.escapeHtml(@title))} + #{highlightTerms @title}
- #{@shortenUrl(@highlightTerms(Utils.escapeHtml(@url)))} + #{@shortenUrl highlightTerms @url} #{relevancyHtml}
""" @@ -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 -- cgit v1.2.3