add moveToEndOfSelection option to moveLEft and moveRight

This commit is contained in:
Ben Ogle
2013-07-22 14:45:18 -07:00
committed by Corey Johnson & Matt Colyer
parent 18370bb663
commit a689a5906e
2 changed files with 23 additions and 9 deletions

View File

@@ -183,15 +183,29 @@ class Cursor
@goalColumn = column
# Moves the cursor left one screen column.
moveLeft: ->
{ row, column } = @getScreenPosition()
[row, column] = if column > 0 then [row, column - 1] else [row - 1, Infinity]
@setScreenPosition({row, column})
#
# options -
# moveToEndOfSelection: true will move to the left of the selection if a selection
moveLeft: ({moveToEndOfSelection}={}) ->
range = @marker.getScreenRange()
if moveToEndOfSelection and not range.isEmpty()
@setScreenPosition(range.start)
else
{row, column} = @getScreenPosition()
[row, column] = if column > 0 then [row, column - 1] else [row - 1, Infinity]
@setScreenPosition({row, column})
# Moves the cursor right one screen column.
moveRight: ->
{ row, column } = @getScreenPosition()
@setScreenPosition([row, column + 1], skipAtomicTokens: true, wrapBeyondNewlines: true, wrapAtSoftNewlines: true)
#
# options -
# moveToEndOfSelection: true will move to the right of the selection if a selection
moveRight: ({moveToEndOfSelection}={}) ->
range = @marker.getScreenRange()
if moveToEndOfSelection and not range.isEmpty()
@setScreenPosition(range.end)
else
{ row, column } = @getScreenPosition()
@setScreenPosition([row, column + 1], skipAtomicTokens: true, wrapBeyondNewlines: true, wrapAtSoftNewlines: true)
# Moves the cursor to the top of the buffer.
moveToTop: ->

View File

@@ -1063,11 +1063,11 @@ class EditSession
# Moves every cursor left one column.
moveCursorLeft: ->
@moveCursors (cursor) -> cursor.moveLeft()
@moveCursors (cursor) -> cursor.moveLeft(moveToEndOfSelection: true)
# Moves every cursor right one column.
moveCursorRight: ->
@moveCursors (cursor) -> cursor.moveRight()
@moveCursors (cursor) -> cursor.moveRight(moveToEndOfSelection: true)
# Moves every cursor to the top of the buffer.
moveCursorToTop: ->