       options = {autoscroll: false, preserveFolds: true}
       selection.setBufferRange(newRange, options)
 
+  getEolBufferPosition: (cursor) ->
+    cursor.getCurrentLineBufferRange().end
+
+  # Cursor motion wrapper
+  # -------------------------
   moveCursorUp: (cursor) ->
     unless @at('FirstScreenRow', cursor)
       cursor.moveUp()

  moveCursorDown: (cursor) ->
    unless @at('LastScreenRow', cursor)
      cursor.moveDown()

  getEolBufferPosition: (cursor) ->
    cursor.getCurrentLineBufferRange().end

  moveCursorRight: (cursor, allowWrap=false) ->
    {row, column} = cursor.getScreenPosition()


  at: (where, cursor) ->
    switch where
      when 'EOL' then cursor.isAtEndOfLine()
      when 'EOF' then cursor.getBufferPosition().isEqual(@getEofBufferPosition())
      when 'FirstScreenRow' then cursor.getScreenRow() is 0
      when 'LastBufferRow' then cursor.getBufferRow() is @getLastBufferRow()
      when 'LastScreenRow' then cursor.getScreenRow() is @getLastScreenRow()

  moveToFirstCharacterOfLine: (cursor) ->
    cursor.moveToBeginningOfLine()
