aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-01-06 05:39:25 +0000
committerStephen Blott2015-01-06 05:39:25 +0000
commit30dee76c6ab1de9e2a62701dacffc29fa5be0866 (patch)
tree1aab7586b612a92222a4cfe85f4d4f5173e236bc /background_scripts/completion.coffee
parent3620fec662ab89bd4f7827e66deec49ff4d11b8e (diff)
parentfc2201b996e47ca06090e10e4ebfcd9f4b345fde (diff)
downloadvimium-30dee76c6ab1de9e2a62701dacffc29fa5be0866.tar.bz2
Merge pull request #1407 from smblott-github/post-1.46
Merge post-1.46 in its entirety
Diffstat (limited to 'background_scripts/completion.coffee')
-rw-r--r--background_scripts/completion.coffee18
1 files changed, 12 insertions, 6 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index d62f82fe..d6402019 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -324,11 +324,17 @@ class SearchEngineCompleter
searchEngines: {}
filter: (queryTerms, onComplete) ->
- searchEngineMatch = this.getSearchEngineMatches(queryTerms[0])
+ {url: url, description: description} = @getSearchEngineMatches queryTerms
suggestions = []
- if searchEngineMatch
- searchEngineMatch = searchEngineMatch.replace(/%s/g, Utils.createSearchQuery queryTerms[1..])
- suggestion = new Suggestion(queryTerms, "search", searchEngineMatch, queryTerms[0] + ": " + queryTerms[1..].join(" "), @computeRelevancy)
+ if url
+ url = url.replace(/%s/g, Utils.createSearchQuery queryTerms[1..])
+ if description
+ type = description
+ query = queryTerms[1..].join " "
+ else
+ type = "search"
+ query = queryTerms[0] + ": " + queryTerms[1..].join(" ")
+ suggestion = new Suggestion(queryTerms, type, url, query, @computeRelevancy)
suggestions.push(suggestion)
onComplete(suggestions)
@@ -337,8 +343,8 @@ class SearchEngineCompleter
refresh: ->
this.searchEngines = root.Settings.getSearchEngines()
- getSearchEngineMatches: (queryTerm) ->
- this.searchEngines[queryTerm]
+ getSearchEngineMatches: (queryTerms) ->
+ (1 < queryTerms.length and @searchEngines[queryTerms[0]]) or {}
# A completer which calls filter() on many completers, aggregates the results, ranks them, and returns the top
# 10. Queries from the vomnibar frontend script come through a multi completer.