 
 class MoveVertically extends Motion
   execute: (count=1) ->
-    {row, column} = @editor.getCursorScreenPosition()
+    {row, column} = @editor.getCursorBufferPosition()
 
     nextRow = @nextValidRow(count)
 

      row

class MoveUp extends MoveVertically
  nextValidRow: (count) ->
    @nextValidRowWithIncrement(count, -1)

  select: (count=1) ->
    _.times count, =>

  #
  # count - The number of folded 'buffer' rows away from
  #         the current row.
  #
  # Returns an integer row index.
  nextValidRow: (count) ->
    {row, column} = @editor.getCursorBufferPosition()

    maxRow = @editor.getLastBufferRow()
    minRow = 0

    # For each count, add 1 'directionIncrement' to
    # row. Folded rows count as a single row.
    _.times count, =>
      if @editor.isFoldedAtBufferRow(row)
        while @editor.isFoldedAtBufferRow(row)
          row += @directionIncrement()
      else
        row += @directionIncrement()

    if row > maxRow
      maxRow
