From ba4e8018e3d8cd80e0fa9ac541e37e7eee37028f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 2 May 2015 17:32:28 +0100 Subject: Search completion; tweaks and refactoring. --- pages/vomnibar.coffee | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'pages') 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 -- cgit v1.2.3