diff options
| author | Stephen Blott | 2015-05-18 06:49:18 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-18 06:49:20 +0100 |
| commit | 4309dcd3030687f3ed02b86bbdf7c485baaee4a5 (patch) | |
| tree | f1d88af43e4fc9ede155dd221b2cabb448ba61d7 | |
| parent | b50c1fe710f1c33d76410dedcf8551c1a1772cba (diff) | |
| download | vimium-4309dcd3030687f3ed02b86bbdf7c485baaee4a5.tar.bz2 | |
Search completion; promote the top completion.
This puts the first (top) completion suggestion at the top of the list:
either one or two <Tab>s away, depending upon whether a domain-completer
suggestion is present or not.
| -rw-r--r-- | background_scripts/completion.coffee | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 1f0a0019..22740128 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -10,7 +10,7 @@ # - refresh(): (optional) refreshes the completer's data source (e.g. refetches the list of bookmarks). # - cancel(): (optional) cancels any pending, cancelable action. class Suggestion - showRelevancy: true # Set this to true to render relevancy when debugging the ranking scores. + showRelevancy: false # Set this to true to render relevancy when debugging the ranking scores. constructor: (@options) -> # Required options. @@ -281,7 +281,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 ].filter (s) -> 0 < s.url.length # Returns a list of domains of the form: [ [domain, relevancy], ... ] @@ -477,22 +477,28 @@ class SearchEngineCompleter type: description url: Utils.createSearchUrl queryTerms, searchUrl title: queryTerms.join " " - relevancy: 1 + relevancy: 2 autoSelect: custom forceAutoSelect: custom highlightTerms: not haveCompletionEngine - mkSuggestion = (suggestion) => - new Suggestion - queryTerms: queryTerms - type: description - url: Utils.createSearchUrl suggestion, searchUrl - title: suggestion - insertText: suggestion - highlightTerms: false - isCustomSearch: custom - relevancyFunction: @computeRelevancy - relevancyData: factor + mkSuggestion = do => + count = 0 + (suggestion) => + console.log count + new Suggestion + queryTerms: queryTerms + type: description + url: Utils.createSearchUrl suggestion, searchUrl + title: suggestion + insertText: suggestion + highlightTerms: false + 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. + relevancy: if 0 < count++ then null else 1 + relevancyFunction: @computeRelevancy + relevancyData: factor cachedSuggestions = if haveCompletionEngine then CompletionSearch.complete searchUrl, queryTerms else null |
