       # because the normal method (below) does not work within text areas, etc.
       length = @selection.toString().length
       @collapseSelectionToFocus()
-      @runMovement @opposite[direction], character for [0...length]
+      for [0...length] by 1
+        @runMovement @opposite[direction], character
     else
       # Normal method.
       original = @selection.getRangeAt(0).cloneRange()

    # character-by-character.
    if granularity == vimword and direction == forward
      while @nextCharacterIsWordCharacter()
        return unless @runMovements [ forward, character ]
      while @getNextForwardCharacter() and not @nextCharacterIsWordCharacter()
        return unless @runMovements [ forward, character ]

    else if granularity == vimword
      @selection.modify @alterMethod, backward, word

    # As above, we implement this character-by-character to get consistent behavior on Windows and Linux.
    if granularity == word and direction == forward
      while @getNextForwardCharacter() and not @nextCharacterIsWordCharacter()
        return unless @runMovements [ forward, character ]
      while @nextCharacterIsWordCharacter()
        return unless @runMovements [ forward, character ]

    else
      @selection.modify @alterMethod, direction, granularity



# This implements various selection movements.
class Movement

  constructor: (@alterMethod) ->
    @opposite = forward: backward, backward: forward
    @selection = window.getSelection()

  # Return the character following (to the right of) the focus, and leave the selection unchanged, or return
