aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vomnibar.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'content_scripts/vomnibar.coffee')
-rw-r--r--content_scripts/vomnibar.coffee14
1 files changed, 12 insertions, 2 deletions
diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee
index 6782ab28..6997d387 100644
--- a/content_scripts/vomnibar.coffee
+++ b/content_scripts/vomnibar.coffee
@@ -68,8 +68,18 @@ class VomnibarUI
@update(true)
updateSelection: ->
+ # We have taken the option to add some global state here (previousCompletionType) to tell if a search
+ # item has just appeared or disappeared, if that happens we either set the initialSelectionValue to 0 or 1
+ # I feel that this approach is cleaner than bubbling the state up from the suggestion level
+ # so we just inspect it afterwards
+ if @completions[0]
+ if @previousCompletionType != "search" && @completions[0].type == "search"
+ @selection = 0
+ else if @previousCompletionType == "search" && @completions[0].type != "search"
+ @selection = -1
for i in [0...@completionList.children.length]
@completionList.children[i].className = (if i == @selection then "vomnibarSelected" else "")
+ @previousCompletionType = @completions[0].type if @completions[0]
#
# Returns the user's action ("up", "down", "enter", "dismiss" or null) based on their keypress.
@@ -192,8 +202,8 @@ class BackgroundCompleter
filter: (query, callback) ->
id = Utils.createUniqueId()
- @filterPort.onMessage.addListener (msg) ->
- return if (msg.id != id)
+ @filterPort.onMessage.addListener (msg) =>
+ @filterPort.onMessage.removeListener(arguments.callee)
# 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].