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 | |
| 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.
| -rw-r--r-- | background_scripts/completion.coffee | 8 | ||||
| -rw-r--r-- | pages/vomnibar.coffee | 18 | 
2 files changed, 13 insertions, 13 deletions
| diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 25c31be1..d5c6c23a 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -436,7 +436,6 @@ class SearchEngineCompleter            searchUrl: url            description: description            searchUrlPrefix: url.split("%s")[0] -          insertTextPrefix: "#{keyword} "        callback engines @@ -550,14 +549,15 @@ class SearchEngineCompleter      return unless request.searchEngines      engines = (engine for _, engine of request.searchEngines)      engines.sort (a,b) -> b.searchUrl.length - a.searchUrl.length -    engines.push insertTextPrefix: null, searchUrl: Settings.get "searchUrl" +    engines.push keyword: null, description: "search", searchUrl: Settings.get "searchUrl"      for suggestion in suggestions        unless suggestion.isSearchSuggestion or suggestion.insertText          for engine in engines            if suggestion.insertText = Utils.extractQuery engine.searchUrl, suggestion.url -            suggestion.insertPrefixOnInput = engine.insertTextPrefix +            suggestion.customSearchMode = engine.keyword              suggestion.title = suggestion.insertText -            suggestion.type = engine.description ? "search" +            console.log suggestion.insertText, engine unless engine.description +            suggestion.type = engine.description ? "custom search"              break      delete request.searchEngines 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 = "" | 
