mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
add moveToEndOfSelection option to moveLEft and moveRight
This commit is contained in:
committed by
Corey Johnson & Matt Colyer
parent
18370bb663
commit
a689a5906e
@@ -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: ->
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user