mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Retain goal column when moving up on first line.
Also: Respect a goal column of 0 when moving down on last line and then back up. (Unlike TextMate)
This commit is contained in:
@@ -19,31 +19,32 @@ class Cursor extends Template
|
||||
|
||||
moveUp: ->
|
||||
{ row, col } = @getPosition()
|
||||
if row is 0
|
||||
col = 0
|
||||
col = @goalColumn if @goalColumn?
|
||||
if row > 0
|
||||
@setPosition({row: row - 1, col: col})
|
||||
else
|
||||
row--
|
||||
|
||||
col = @goalColumn if @goalColumn
|
||||
@setPosition({row, col})
|
||||
@goalColumn ?= col
|
||||
|
||||
moveDown: ->
|
||||
{ row, col } = @getPosition()
|
||||
|
||||
col = @goalColumn if @goalColumn
|
||||
if row < @parentView.buffer.numLines() - 1
|
||||
row++
|
||||
@setPosition({row, col})
|
||||
else
|
||||
@moveToEndOfLine()
|
||||
@moveToLineStart()
|
||||
|
||||
@goalColumn = col
|
||||
|
||||
moveToEndOfLine: ->
|
||||
moveDown: ->
|
||||
{ row, col } = @getPosition()
|
||||
col = @goalColumn if @goalColumn?
|
||||
if row < @parentView.buffer.numLines() - 1
|
||||
@setPosition({row: row + 1, col: col})
|
||||
else
|
||||
@moveToLineEnd()
|
||||
|
||||
@goalColumn = col
|
||||
|
||||
moveToLineEnd: ->
|
||||
{ row } = @getPosition()
|
||||
@setPosition({ row, col: @parentView.buffer.getLine(row).length })
|
||||
|
||||
moveToLineStart: ->
|
||||
{ row } = @getPosition()
|
||||
@setPosition({ row, col: 0 })
|
||||
|
||||
moveRight: ->
|
||||
{ row, col } = @getPosition()
|
||||
if col < @parentView.buffer.getLine(row).length
|
||||
|
||||
Reference in New Issue
Block a user