aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-06-06 12:01:23 +0100
committerStephen Blott2015-06-06 12:01:25 +0100
commit4eda19de339212f86a9b008a4f3142a61d62829e (patch)
treedc9c314b327baf8cdebb05062087413431090cab /background_scripts/completion.coffee
parent2d5a01c9791a81aa87eaa935a1183f10950bdc84 (diff)
downloadvimium-4eda19de339212f86a9b008a4f3142a61d62829e.tar.bz2
Re-work completions: extend engine wrapper to handle prefixes.
This commit contains the bulk og the material changes for which the previous commits established the basis. 1) Add a general framework for detecting query prefixes in search URLs, adding them to query sent to the completion engine, and stripping them from the resulting suggestions. This allows the user to have a search engine... j: http://www.google.com/search?q=javascript+%s Javascript and have the prefix "javascript" included (automatically) in queries sent to completion engines, which results in substantially better suggestions. 2) Re-work completion for Google Maps in a simpler form.
Diffstat (limited to 'background_scripts/completion.coffee')
-rw-r--r--background_scripts/completion.coffee13
1 files changed, 8 insertions, 5 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index c83066a6..6b58f4ea 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -450,7 +450,7 @@ class SearchEngineCompleter
{ keyword, searchUrl, description } = engine
extend request, searchUrl, customSearchMode: true
- factor = 0.5
+ @previousSuggestions[searchUrl] ?= []
haveCompletionEngine = CompletionSearch.haveCompletionEngine searchUrl
# This filter is applied to all of the suggestions from all of the completers, after they have been
@@ -466,13 +466,14 @@ class SearchEngineCompleter
)
# If a previous suggestion still matches the query, then we keep it (even if the completion engine may not
- # return it for the current query). This allows the user to pick suggestions by typing fragments of their
- # text, without regard to whether the completion engine can complete the actual text of the query.
+ # return it for the current query). This allows the user to pick suggestions they've previously seen by
+ # typing fragments of their text, without regard to whether the completion engine can continue to complete
+ # the actual text of the query.
previousSuggestions =
if queryTerms.length == 0
[]
else
- for url, suggestion of @previousSuggestions
+ for url, suggestion of @previousSuggestions[searchUrl]
continue unless RankingUtils.matches queryTerms, suggestion.title
# Reset various fields, they may not be correct wrt. the current query.
extend suggestion, relevancy: null, html: null, queryTerms: queryTerms
@@ -484,6 +485,7 @@ class SearchEngineCompleter
type: description
url: Utils.createSearchUrl queryTerms, searchUrl
title: queryTerms.join " "
+ searchUrl: searchUrl
relevancy: 2.0
autoSelect: true
highlightTerms: false
@@ -496,11 +498,12 @@ class SearchEngineCompleter
count = 0
(suggestion) =>
url = Utils.createSearchUrl suggestion, searchUrl
- @previousSuggestions[url] = new Suggestion
+ @previousSuggestions[searchUrl][url] = new Suggestion
queryTerms: queryTerms
type: description
url: url
title: suggestion
+ searchUrl: searchUrl
insertText: suggestion
highlightTerms: false
highlightTermsExcludeUrl: true