aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-05-04 13:29:48 +0100
committerStephen Blott2015-05-04 13:29:48 +0100
commit44b24f43a30e2f2ebe47e70e74413488ad3a676f (patch)
tree84eaae139c6b2988878de7463b932e9d87344352
parent7f99155824edd7424bd28feae401459da6a2ba8f (diff)
downloadvimium-44b24f43a30e2f2ebe47e70e74413488ad3a676f.tar.bz2
Search completion; fix mistake with autoSelect.
-rw-r--r--background_scripts/completion.coffee2
-rw-r--r--pages/vomnibar.coffee24
2 files changed, 13 insertions, 13 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 1c07a71a..d206a285 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -24,7 +24,7 @@ class Suggestion
# When @autoSelect is truthy, the suggestion is automatically pre-selected in the vomnibar.
@autoSelect = false
# If @noHighlightTerms is falsy, then we don't highlight matched terms in the title and URL.
- @autoSelect = true
+ @noHighlightTerms = false
# If @insertText is a string, then the indicated text is inserted into the vomnibar input when the
# suggestion is selected.
@insertText = null
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index c029dc20..468736bb 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -82,28 +82,29 @@ class VomnibarUI
@updateTimer = null
@completions = []
@previousAutoSelect = null
- @previousText = null
+ @previousInputValue = null
@selection = @initialSelectionValue
updateSelection: ->
# We retain global state here (previousAutoSelect) to tell if a search item (for which autoSelect is set)
# has just appeared or disappeared. If that happens, we set @selection to 0 or -1.
- if @completions[0]
+ if 0 < @completions.length
@selection = 0 if @completions[0].autoSelect and not @previousAutoSelect
@selection = -1 if @previousAutoSelect and not @completions[0].autoSelect
@previousAutoSelect = @completions[0].autoSelect
- for i in [0...@completionList.children.length]
- @completionList.children[i].className = (if i == @selection then "vomnibarSelected" else "")
# For suggestions from search-engine completion, we copy the suggested text into the input when selected,
# and revert when not. This allows the user to select a suggestion and then continue typing.
if 0 <= @selection and @completions[@selection].insertText?
- @previousText ?= @input.value
- suggestion = @completions[@selection]
+ @previousInputValue ?= @input.value
@input.value = @completions[@selection].insertText
- else if @previousText?
- @input.value = @previousText
- @previousText = null
+ else if @previousInputValue?
+ @input.value = @previousInputValue
+ @previousInputValue = null
+
+ # Highlight the the selected entry, and only the selected entry.
+ for i in [0...@completionList.children.length]
+ @completionList.children[i].className = (if i == @selection then "vomnibarSelected" else "")
#
# Returns the user's action ("up", "down", "enter", "dismiss" or null) based on their keypress.
@@ -182,9 +183,8 @@ class VomnibarUI
if (updateSynchronously)
# The user entered something. Don't reset any previous text, and re-enable custom search engine auto
# selection.
- if @previousText?
- @previousText = null
- @previousAutoSelect = null
+ if @previousInputValue? and updateSynchronously.type == "input"
+ @previousInputValue = null
@selection = -1
# cancel scheduled update
if @updateTimer?