diff options
| author | Stephen Blott | 2015-01-31 13:34:36 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-31 13:34:36 +0000 |
| commit | d03ba099fcbe5e07dfdfa454afdb86fd5aad2c89 (patch) | |
| tree | c8f26c521c3cd89bdf16bcc598a6bc5b54292508 | |
| parent | 11199de98a2c29601e38e75af561057ab55a0a83 (diff) | |
| download | vimium-d03ba099fcbe5e07dfdfa454afdb86fd5aad2c89.tar.bz2 | |
Visual/edit modes: character-by-character word movements.
| -rw-r--r-- | content_scripts/mode_visual_edit.coffee | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee index 253d892a..a170a2da 100644 --- a/content_scripts/mode_visual_edit.coffee +++ b/content_scripts/mode_visual_edit.coffee @@ -124,10 +124,8 @@ class Movement extends CountPrefix beforeText[beforeText.length - 1] # Test whether the character following the focus is a word character. Leave the selection unchanged. - # We include "." as a word character here. With this, "w" sometimes jumps one word too far. However, it's - # better than leaving it out, in which case "w" jumps backwards! nextCharacterIsWordCharacter: do -> - regexp = /[A-Za-z0-9_]|\./ + regexp = /[A-Za-z0-9_]/ -> regexp.test @getNextForwardCharacter() # Run a movement. For convenience, the following three argument forms are available: @@ -146,16 +144,24 @@ class Movement extends CountPrefix else if args.length == 1 then args[0] else args[...2] - # Perform the movement. + # Word movements are different on Linux and Windows, see #1441. So we implement some of them + # character-by-character. if movement[1] == vimword and movement[0] == forward - if @nextCharacterIsWordCharacter() - @runMovements [ forward, word ], [ forward, word ], [ backward, word ] - else - @runMovements [ forward, word ], [ backward, word ] + while @nextCharacterIsWordCharacter() + return unless @runMovements [ forward, character ] + while @getNextForwardCharacter() and not @nextCharacterIsWordCharacter() + return unless @runMovements [ forward, character ] else if movement[1] == vimword @selection.modify @alterMethod, backward, word + # As above, we implement this character-by-character to get consistent behavior on Windows and Linux. + if movement[1] == word and movement[0] == forward + while @getNextForwardCharacter() and not @nextCharacterIsWordCharacter() + return unless @runMovements [ forward, character ] + while @nextCharacterIsWordCharacter() + return unless @runMovements [ forward, character ] + else @selection.modify @alterMethod, movement... |
