aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-05-15 08:17:16 +0100
committerStephen Blott2015-05-15 08:17:19 +0100
commit6a322975f561764d1a4ecb8ebd32edea12909e80 (patch)
treea6fc172db4eaf6b0e5aa041f3fe21f77d38d0064
parentb425d1804912ceb654e3b0070d9f2a2eb65a751e (diff)
downloadvimium-6a322975f561764d1a4ecb8ebd32edea12909e80.tar.bz2
Give the vomnibar a (kind of) history (autoSelect).
If we insert the text of hostory completions into the vomnibar input, then when the completions change, we'll pick up the arbitrary text of whatever happens to be the current selection. So we need to always reset the selection when the vomnibar updates. This eliminates the need for the previous autoSelect logic.
-rw-r--r--background_scripts/completion.coffee1
-rw-r--r--pages/vomnibar.coffee15
2 files changed, 2 insertions, 14 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index fd0a4c51..ac234787 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -504,7 +504,6 @@ class SearchEngineCompleter
title: queryTerms.join " "
relevancy: 1
autoSelect: custom
- forceAutoSelect: custom
highlightTerms: not haveCompletionEngine
mkSuggestion = (suggestion) ->
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index a20ae7f3..07eb39bb 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -67,22 +67,12 @@ class VomnibarUI
@completionList.style.display = ""
@input.value = ""
@completions = []
- @previousAutoSelect = null
@previousInputValue = null
@customSearchMode = null
@selection = @initialSelectionValue
@keywords = []
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 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
- else
- @previousAutoSelect = null
-
# For custom search engines, we suppress the leading term (e.g. the "w" of "w query terms") within the
# vomnibar input.
if @lastReponse.customSearchMode and not @customSearchMode?
@@ -185,20 +175,19 @@ class VomnibarUI
callback: (@lastReponse) =>
{ results } = @lastReponse
@completions = results
+ @selection = if @completions[0]?.autoSelect then 0 else @initialSelectionValue
# Update completion list with the new suggestions.
@completionList.innerHTML = @completions.map((completion) -> "<li>#{completion.html}</li>").join("")
@completionList.style.display = if @completions.length > 0 then "block" else ""
@selection = Math.min @completions.length - 1, Math.max @initialSelectionValue, @selection
- @previousAutoSelect = null if @completions[0]?.autoSelect and @completions[0]?.forceAutoSelect
@updateSelection()
callback?()
updateOnInput: =>
@completer.cancel()
- # If the user types, then don't reset any previous text, and restart auto select.
+ # If the user types, then don't reset any previous text, and reset the selection.
if @previousInputValue?
@previousInputValue = null
- @previousAutoSelect = null
@selection = -1
@update false