diff options
| author | Stephen Blott | 2015-05-12 15:06:24 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-12 15:11:48 +0100 |
| commit | b012edc7166d229c48232f077ffe4275b4f06d91 (patch) | |
| tree | d145e0a490cd6a6a71ed87b9ad13ddce6b40f4c0 /pages | |
| parent | db7f7a8d7c2f7fa3f372a29eee14709a2156a76b (diff) | |
| download | vimium-b012edc7166d229c48232f077ffe4275b4f06d91.tar.bz2 | |
Prevent immediate re-completion
This prevents an immediate re-completion after the user has repositioned
the cursor with the arrow keys (which is an odd UX).
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/vomnibar.coffee | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 2aa70379..6bfa2474 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -120,9 +120,6 @@ class VomnibarUI # Bail if we don't yet have the background completer's final word on the current query. return unless response.mayCacheResults - # Bail if there's an update pending (because then @input and the completion state are out of sync). - return if @updateTimer? - value = @getInputWithoutPromptedText() @previousLength ?= value.length previousLength = @previousLength @@ -132,6 +129,9 @@ class VomnibarUI return unless previousLength < currentLength return if /^\s/.test(value) or /\s\s/.test value + # Bail if there's an update pending (because then @input and the completion state are out of sync). + return if @updateTimer? + completions = @completions.filter (completion) -> completion.customSearchEngineCompletionSuggestion return unless 0 < completions.length @@ -168,8 +168,8 @@ class VomnibarUI return "enter" else if event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey return "delete" - else if key in [ "left", "right" ] and event.ctrlKey and not (event.altKey or event.metaKey) - return "control-#{key}" + else if key in [ "left", "right" ] + return key null @@ -228,23 +228,23 @@ class VomnibarUI @suppressedLeadingKeyword = null @updateCompletions() else - # Don't suppress the Delete. We want it to happen. - return true - else if action == "control-right" - [ start, end ] = [ @input.selectionStart, @input.selectionEnd ] - return true unless @inputContainsASelectionRange() and end == @input.value.length - # "Control-Right" advances the start of the selection by a word. - text = @input.value[start...end] - newText = text.replace /^\s*\S+\s*/, "" - @input.setSelectionRange start + (text.length - newText.length), end - - else if action == "control-left" + return true # Do not suppress event. + else if action in [ "left", "right" ] [ start, end ] = [ @input.selectionStart, @input.selectionEnd ] - return true unless @inputContainsASelectionRange() and end == @input.value.length - # "Control-Left" extends the start of the selection to the start of the current word. - text = @input.value[0...start] - newText = text.replace /\S+\s*$/, "" - @input.setSelectionRange start + (newText.length - text.length), end + @previousLength = end + if event.ctrlKey and not (event.altKey or event.metaKey) + return true unless @inputContainsASelectionRange() and end == @input.value.length + # "Control-Right" advances the start of the selection by a word. + text = @input.value[start...end] + switch action + when "right" + newText = text.replace /^\s*\S+\s*/, "" + @input.setSelectionRange start + (text.length - newText.length), end + when "left" + newText = text.replace /\S+\s*$/, "" + @input.setSelectionRange start + (newText.length - text.length), end + else + return true # Do not suppress event. # It seems like we have to manually suppress the event here and still return true. event.stopImmediatePropagation() |
