From 802a4259e9bbd86884c2696ffaa8158fabc99490 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 20 Apr 2012 18:11:01 -0600 Subject: [PATCH] Move-to-first-character-of-line no longer explodes on empty lines --- spec/app/editor-spec.coffee | 4 ++++ src/app/cursor.coffee | 1 + 2 files changed, 5 insertions(+) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 7622fc24f..fc1c460c8 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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] diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index de3d714d2..0ace75a49 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -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)