diff options
| author | Stephen Blott | 2015-05-08 07:35:31 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-08 07:35:31 +0100 |
| commit | 898c21808c709a1a551fa15bb82f6a3bb4810aae (patch) | |
| tree | c875b5d5523c1b24288bd106cfaaf53a7a67a4af | |
| parent | 908eac76062a45e5c8f686fccc9f91b16d8a23bf (diff) | |
| download | vimium-898c21808c709a1a551fa15bb82f6a3bb4810aae.tar.bz2 | |
Search completion; refactor vomnibar launch.
| -rw-r--r-- | pages/vomnibar.coffee | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 503ae1f5..29dc4a82 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -73,8 +73,10 @@ class VomnibarUI reset: -> @completionList.style.display = "" @input.value = "" - @updateTimer = null @completions = [] + window.clearTimeout @updateTimer if @updateTimer? + @updateTimer = null + @mostRecentQuery = null @previousAutoSelect = null @previousInputValue = null @selection = @initialSelectionValue @@ -151,9 +153,7 @@ class VomnibarUI url: query else completion = @completions[@selection] - @update true, => - # Shift+Enter will open the result in a new tab instead of the current tab. - @hide -> completion.performAction openInNewTab + @hide -> completion.performAction openInNewTab # It seems like we have to manually suppress the event here and still return true. event.stopImmediatePropagation() @@ -230,14 +230,13 @@ class BackgroundCompleter # 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, search], or a custom search engine description. - results = msg.results.map (result) => - functionToCall = if result.type == "tab" - @completionActions.switchToTab.curry result.tabId - else - @completionActions.navigateToUrl.curry result.url - result.performAction = functionToCall - result - @mostRecentCallback results + for result in msg.results + result.performAction = + if result.type == "tab" + @completionActions.switchToTab.curry result.tabId + else + @completionActions.navigateToUrl.curry result.url + @mostRecentCallback msg.results filter: (query, @mostRecentCallback) -> # Ignore identical consecutive queries. This can happen, for example, if the user adds whitespace to the |
