aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-05-28 10:26:22 +0100
committerStephen Blott2015-05-28 10:30:12 +0100
commit4b4fb7957e89adddcf454c56e902f2c3395eadbc (patch)
treeb18df2204e1d1e4d0a6847fd827b27278af68125
parentded18f3bb0eb8cf2e559ff44a46564fd002a4b33 (diff)
downloadvimium-4b4fb7957e89adddcf454c56e902f2c3395eadbc.tar.bz2
Custom-only: ensure top-ranking completion is always in top slot.
This ensures that <Tab> can always be used to complete the top-ranking completion.
-rw-r--r--background_scripts/completion.coffee35
1 files changed, 19 insertions, 16 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index aa7ed4bc..8f8754f8 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -301,7 +301,7 @@ class DomainCompleter
queryTerms: queryTerms
type: "domain"
url: domains[0]?[0] ? "" # This is the URL or an empty string, but not null.
- relevancy: 1
+ relevancy: 2.0
].filter (s) -> 0 < s.url.length
# Returns a list of domains of the form: [ [domain, relevancy], ... ]
@@ -501,35 +501,38 @@ class SearchEngineCompleter
type: description
url: Utils.createSearchUrl queryTerms, searchUrl
title: queryTerms.join " "
- relevancy: 1
+ relevancy: 2.0
autoSelect: true
highlightTerms: false
isSearchSuggestion: true
return onComplete [ primarySuggestion ], { filter } if queryTerms.length == 0
- mkSuggestion = (suggestion) =>
- url = Utils.createSearchUrl suggestion, searchUrl
- @previousSuggestions[url] = new Suggestion
- queryTerms: queryTerms
- type: description
- url: url
- title: suggestion
- insertText: suggestion
- highlightTerms: false
- highlightTermsExcludeUrl: true
- isCustomSearch: true
- relevancyFunction: @computeRelevancy
+ mkSuggestion = do =>
+ count = 0
+ (suggestion) =>
+ url = Utils.createSearchUrl suggestion, searchUrl
+ @previousSuggestions[url] = new Suggestion
+ queryTerms: queryTerms
+ type: description
+ url: url
+ title: suggestion
+ insertText: suggestion
+ highlightTerms: false
+ highlightTermsExcludeUrl: true
+ isCustomSearch: true
+ relevancy: if ++count == 1 then 1.0 else null
+ relevancyFunction: @computeRelevancy
cachedSuggestions =
if haveCompletionEngine then CompletionSearch.complete searchUrl, queryTerms else null
suggestions = previousSuggestions
suggestions.push primarySuggestion
- suggestions.push cachedSuggestions.map(mkSuggestion)... if cachedSuggestions?
if queryTerms.length == 0 or cachedSuggestions? or not haveCompletionEngine
- # There is no prospect of adding further completions.
+ # There is no prospect of adding further completions, so we're done.
+ suggestions.push cachedSuggestions.map(mkSuggestion)... if cachedSuggestions?
onComplete suggestions, { filter, continuation: null }
else
# Post the initial suggestions, but then deliver any further completions asynchronously, as a