diff options
| author | Stephen Blott | 2015-05-08 06:56:09 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-08 06:56:09 +0100 |
| commit | 908eac76062a45e5c8f686fccc9f91b16d8a23bf (patch) | |
| tree | fe1c4d61f60b98f3e4961278316a8f085056ea3b /pages | |
| parent | 723b66e24f9b3f4e8dd9843e21352eeceb7c96a9 (diff) | |
| download | vimium-908eac76062a45e5c8f686fccc9f91b16d8a23bf.tar.bz2 | |
Search completion; refactor query terms.
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/vomnibar.coffee | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 62c37443..503ae1f5 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -161,7 +161,7 @@ class VomnibarUI true updateCompletions: (callback = null) -> - @completer.filter @input.value.trim(), (@completions) => + @completer.filter @input.value, (@completions) => @populateUiWithCompletions @completions callback?() @@ -229,7 +229,7 @@ class BackgroundCompleter if msg.id == @messageId # The result objects coming from the background page will be of the form: # { html: "", type: "", url: "" } - # type will be one of [tab, bookmark, history, domain]. + # Type will be one of [tab, bookmark, history, domain, search], or a custom search engine description. results = msg.results.map (result) => functionToCall = if result.type == "tab" @completionActions.switchToTab.curry result.tabId @@ -240,12 +240,14 @@ class BackgroundCompleter @mostRecentCallback results filter: (query, @mostRecentCallback) -> - # Ignore identical consecutive queries. This can happen, for example, if the user adds a <SPACE> to the - # query. + # Ignore identical consecutive queries. This can happen, for example, if the user adds whitespace to the + # query. We normalize the query first to ensure that differences only in whitespace are ignored. + queryTerms = query.trim().split(/\s+/).filter (term) -> 0 < term.length + query = queryTerms.join " " unless @mostRecentQuery? and query == @mostRecentQuery @mostRecentQuery = query @messageId = Utils.createUniqueId() - @port.postMessage name: @name, handler: "filter", id: @messageId, query: query + @port.postMessage name: @name, handler: "filter", id: @messageId, queryTerms: queryTerms refresh: -> @port.postMessage name: @name, handler: "refresh" |
