Move-to-first-character-of-line no longer explodes on empty lines

This commit is contained in:
Nathan Sobo
2012-04-20 18:11:01 -06:00
parent a6afc319c6
commit 802a4259e9
2 changed files with 5 additions and 0 deletions

View File

@@ -427,6 +427,10 @@ describe "Editor", ->
expect(cursor1.getBufferPosition()).toEqual [0,0]
expect(cursor2.getBufferPosition()).toEqual [1,0]
it "does not throw an exception on an empty line", ->
editor.setCursorBufferPosition([10, 0])
editor.trigger 'move-to-first-character-of-line'
describe "move-to-next-word", ->
it "moves the cursor to the next word or the end of file if there is no next word", ->
editor.setCursorBufferPosition [2, 5]

View File

@@ -144,6 +144,7 @@ class Cursor extends View
newPosition = null
@editor.scanInRange /^\s*/, range, (match, matchRange) =>
newPosition = matchRange.end
return unless newPosition
newPosition = [position.row, 0] if newPosition.isEqual(position)
@setBufferPosition(newPosition)