aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-05-18 08:45:21 +0100
committerStephen Blott2015-05-18 08:45:43 +0100
commita1e26d83b7f34ad230a51cdb4cb17224522a39dd (patch)
treedf082f82c6141dcf42c8e21b0cd548a3c66d8d6b /background_scripts/completion.coffee
parent4ec5e46ece2cd12d5ebb8db6a8ebcb8690687a1f (diff)
downloadvimium-a1e26d83b7f34ad230a51cdb4cb17224522a39dd.tar.bz2
Search completion; retain previous suggestions (tweak highlighting).
Diffstat (limited to 'background_scripts/completion.coffee')
-rw-r--r--background_scripts/completion.coffee10
1 files changed, 7 insertions, 3 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index e6e8deaf..39ec66c5 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -52,7 +52,7 @@ class Suggestion
<span class="vimiumReset vomnibarTitle">#{@highlightQueryTerms Utils.escapeHtml @title}</span>
</div>
<div class="vimiumReset vomnibarBottomHalf">
- <span class="vimiumReset vomnibarUrl">#{@highlightQueryTerms Utils.escapeHtml @shortenUrl()}</span>
+ <span class="vimiumReset vomnibarUrl">#{@highlightUrlTerms Utils.escapeHtml @shortenUrl()}</span>
#{relevancyHtml}
</div>
"""
@@ -114,6 +114,9 @@ class Suggestion
string.substring(end)
string
+ highlightUrlTerms: (string) ->
+ if @highlightTermsExcludeUrl then string else @highlightQueryTerms string
+
# Merges the given list of ranges such that any overlapping regions are combined. E.g.
# mergeRanges([0, 4], [3, 6]) => [0, 6]. A range is [startIndex, endIndex].
mergeRanges: (ranges) ->
@@ -486,8 +489,8 @@ class SearchEngineCompleter
previousSuggestions =
for url, suggestion of @previousSuggestions
continue unless RankingUtils.matches queryTerms, suggestion.title
- # Reset the previous relevancy and HTML, they may not be correct wrt. the current query.
- extend suggestion, relevancy: null, html: null
+ # Reset various fields, they may not be correct wrt. the current query.
+ extend suggestion, relevancy: null, html: null, highlightTerms: true, queryTerms: queryTerms
suggestion.relevancy = null
suggestion
@@ -512,6 +515,7 @@ class SearchEngineCompleter
title: suggestion
insertText: suggestion
highlightTerms: false
+ highlightTermsExcludeUrl: true
isCustomSearch: custom
# The first (top) suggestion gets a score of 1. This puts it two <Tab>s away if a domain completion
# is present (which has a score of 2), and one <Tab> away otherwise.