 
   getScanRows: (cursor) ->
     cursorRow = cursor.getBufferRow()
-    [startRow, endRow] = switch @direction
-      when 'up' then [cursorRow - 1, 0]
-      when 'down' then [cursorRow + 1, getVimLastBufferRow(@editor)]
-    [getValidVimRow(@editor, startRow)..endRow]
+    validRow = getValidVimRow.bind(null, @editor)
+    switch @direction
+      when 'up'
+        [validRow(cursorRow - 1)..0]
+      when 'down'
+        [validRow(cursorRow + 1)..getVimLastBufferRow(@editor)]
 
   isMovableColumn: (row, column) ->
     @isNonBlankColumn(row, column)


  select: ->
    for selection in @editor.getSelections()
      if @isInclusive() or @isLinewise()
        @normalizeVisualModeCursorPosition(selection) if @isMode('visual')
        @selectInclusively(selection)
        @selectLine(selection) if @isLinewise()
      else
        selection.modifySelection =>
          @moveCursor selection.cursor

    @editor.mergeCursors()
    @editor.mergeIntersectingSelections()
    @emitDidSelect()

  selectLine: (selection) ->
    if @isMode('visual', 'linewise')
      swrap(selection).preserveCharacterwise()
    swrap(selection).expandOverLine(preserveGoalColumn: true)

  # Modify selection with keeping tailRange(= range under cursor in most case.).
  # -------------------------
  # * Why we need to allowWrap when moveCursorLeft/Right?
  # When 'linewise' selection, cursor is at column '0' of NEXT line, so we need to moveLeft
  # by wrapping, to put cursor on row which actually be selected(from UX point of view).
  # This adjustment is important so that j, k works without special care in moveCursor.
  selectInclusively: (selection) ->
    {cursor} = selection
    selection.modifySelection =>

  move: (cursor) ->
    moveCursorDown(cursor)

# -------------------------
class MoveUpToNonBlank extends Motion
  @extend()
