diff options
| author | Stephen Blott | 2015-01-06 05:39:25 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-06 05:39:25 +0000 |
| commit | 30dee76c6ab1de9e2a62701dacffc29fa5be0866 (patch) | |
| tree | 1aab7586b612a92222a4cfe85f4d4f5173e236bc /background_scripts/completion.coffee | |
| parent | 3620fec662ab89bd4f7827e66deec49ff4d11b8e (diff) | |
| parent | fc2201b996e47ca06090e10e4ebfcd9f4b345fde (diff) | |
| download | vimium-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.coffee | 18 |
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. |
