Add isOnEOL method to cursor

This commit is contained in:
Corey Johnson
2012-02-06 12:01:52 -08:00
parent 4a8d03b966
commit f3eb6fc66c
2 changed files with 11 additions and 0 deletions

View File

@@ -35,3 +35,11 @@ describe "Cursor", ->
advanceClock(100)
expect(cursor).toHaveClass 'idle'
describe ".isOnEOL()", ->
it "only returns true when cursor is on the end of a line", ->
cursor.setPosition([1,29])
expect(cursor.isOnEOL()).toBeFalsy()
cursor.setPosition([1,30])
expect(cursor.isOnEOL()).toBeTruthy()

View File

@@ -38,6 +38,9 @@ class Cursor extends View
getRow: ->
@getPosition().row
isOnEOL: ->
@getColumn() == @editor.getCurrentLine().length
moveUp: ->
{ row, column } = @getPosition()
column = @goalColumn if @goalColumn?