diff options
| author | Stephen Blott | 2015-05-10 11:40:48 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-05-10 11:46:21 +0100 | 
| commit | 52fbd19e24ae5679d9a2cdb7f1fa16b83c40e308 (patch) | |
| tree | 047419bc88c2d9a10db36702b84aaff0dcb96713 /pages/vomnibar.coffee | |
| parent | e56b5fc0129dd67d7978ee6453d366cb3642a4e2 (diff) | |
| download | vimium-52fbd19e24ae5679d9a2cdb7f1fa16b83c40e308.tar.bz2 | |
Search completion; smooth matched-selection extension.
Diffstat (limited to 'pages/vomnibar.coffee')
| -rw-r--r-- | pages/vomnibar.coffee | 13 | 
1 files changed, 12 insertions, 1 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 2077c559..8c655b07 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -256,6 +256,16 @@ class VomnibarUI      event.preventDefault()      true +  onKeypress: (event) => +    if @inputContainsASelectionRange() +      if @input.value[@input.selectionStart][0] == String.fromCharCode event.charCode +        console.log "extend selection:", @getInputWithoutSelectionRange() +        @input.setSelectionRange @input.selectionStart + 1, @input.selectionEnd +        @update() +        event.stopImmediatePropagation() +        event.preventDefault() +    true +    # Test whether the input contains selected text.    inputContainsASelectionRange: ->      @input.selectionStart? and @input.selectionEnd? and @input.selectionStart != @input.selectionEnd @@ -270,7 +280,7 @@ class VomnibarUI    # Return the background-page query corresponding to the current input state.  In other words, reinstate any    # custom search engine keyword which is currently stripped from the input.    getInputValueAsQuery: -> -    (if @suppressedLeadingKeyword? then @suppressedLeadingKeyword + " " else "") + @input.value +    (if @suppressedLeadingKeyword? then @suppressedLeadingKeyword + " " else "") + @getInputWithoutSelectionRange()    updateCompletions: (callback = null) ->      @completer.filter @getInputValueAsQuery(), (response) => @@ -325,6 +335,7 @@ class VomnibarUI      @input = @box.querySelector("input")      @input.addEventListener "input", @updateOnInput      @input.addEventListener "keydown", @onKeydown +    @input.addEventListener "keypress", @onKeypress      @completionList = @box.querySelector("ul")      @completionList.style.display = ""  | 
