aboutsummaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorStephen Blott2015-05-02 17:32:28 +0100
committerStephen Blott2015-05-03 08:41:55 +0100
commitba4e8018e3d8cd80e0fa9ac541e37e7eee37028f (patch)
treedda565cc9f2d55009329d81405490d467764680b /pages
parent8329f3cbe95e6a39e500aa15e54c6c44fad9cb7e (diff)
downloadvimium-ba4e8018e3d8cd80e0fa9ac541e37e7eee37028f.tar.bz2
Search completion; tweaks and refactoring.
Diffstat (limited to 'pages')
-rw-r--r--pages/vomnibar.coffee17
1 files changed, 6 insertions, 11 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index c519ce3a..3520537e 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -81,6 +81,7 @@ class VomnibarUI
@input.value = ""
@updateTimer = null
@completions = []
+ @previousText = null
@selection = @initialSelectionValue
updateSelection: ->
@@ -94,18 +95,12 @@ class VomnibarUI
@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.
- if 0 <= @selection
+ # 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]
- if suggestion.insertText
- @previousText ?= @input.value
- @input.value = (suggestion.reinsertPrefix ? "") + suggestion.title
- else
- if @previousText?
- @input.value = @previousText
- @previousText = null
- else
- if @previousText?
+ @input.value = (suggestion.reinsertPrefix ? "") + suggestion.title
+ else if @previousText?
@input.value = @previousText
@previousText = null