diff options
| author | Stephen Blott | 2015-05-17 09:30:37 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-17 09:50:45 +0100 |
| commit | 913806699a2cc66aea4489137a84189e01afd9da (patch) | |
| tree | a12c5db5c5fe4063d4618b3db0f1c318fca3b81e /pages/vomnibar.coffee | |
| parent | 832be3c2059870e0930ece3ea88377034e237119 (diff) | |
| download | vimium-913806699a2cc66aea4489137a84189e01afd9da.tar.bz2 | |
TabToOpen: reactivate custom search engines.
When the user begins editing the inserted text from a
custom-search-engine suggestion, we reactivate the original
custom-search-engine mode.
Diffstat (limited to 'pages/vomnibar.coffee')
| -rw-r--r-- | pages/vomnibar.coffee | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 2caec140..c4b22911 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -86,7 +86,7 @@ class VomnibarUI # typing. if 0 <= @selection and @completions[@selection].insertText? @previousInputValue ?= @input.value - @input.value = @completions[@selection].insertText + (if @selection == 0 then "" else " ") + @input.value = @completions[@selection].insertText else if @previousInputValue? @input.value = @previousInputValue @previousInputValue = null @@ -193,11 +193,11 @@ class VomnibarUI @updateSelection() callback?() - updateOnInput: => + onInput: => + @tabToOpen = false @completer.cancel() - updateSynchronously = false - if 0 < @selection and @completions[@selection].insertPrefixOnInput - @input.value = @completions[@selection].insertPrefixOnInput + @input.value + if 0 <= @selection and @completions[@selection].customSearchMode and not @customSearchMode + @customSearchMode = @completions[@selection].customSearchMode updateSynchronously = true # If the user types, then don't reset any previous text, and reset the selection. if @previousInputValue? @@ -210,14 +210,14 @@ class VomnibarUI window.clearTimeout @updateTimer @updateTimer = null - isCustomSearch: -> + shouldActivateCustomSearchMode: -> queryTerms = @input.value.ltrim().split /\s+/ - 1 < queryTerms.length and queryTerms[0] in @keywords + 1 < queryTerms.length and queryTerms[0] in @keywords and not @customSearchMode update: (updateSynchronously = false, callback = null) => # If the query text becomes a custom search (the user enters a search keyword), then we need to force a # synchronous update (so that the state is updated immediately). - updateSynchronously ||= @isCustomSearch() and not @customSearchMode? + updateSynchronously ||= @shouldActivateCustomSearchMode() if updateSynchronously @clearUpdateTimer() @updateCompletions callback @@ -234,7 +234,7 @@ class VomnibarUI @box = document.getElementById("vomnibar") @input = @box.querySelector("input") - @input.addEventListener "input", @updateOnInput + @input.addEventListener "input", @onInput @input.addEventListener "keydown", @onKeydown @completionList = @box.querySelector("ul") @completionList.style.display = "" |
