diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index cdbb394b3..dd0a6c3f1 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -296,6 +296,12 @@ describe "EditSession", -> expect(cursor2.getBufferPosition()).toEqual [1, 13] expect(cursor3.getBufferPosition()).toEqual [3, 4] + it "does not blow up when there is no next word", -> + editSession.setCursorBufferPosition [Infinity, Infinity] + endPosition = editSession.getCursorBufferPosition() + editSession.moveCursorToEndOfWord() + expect(editSession.getCursorBufferPosition()).toEqual endPosition + describe "selection", -> selection = null diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index fa1debab2..4fe6896cf 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -130,7 +130,8 @@ class Cursor @setBufferPosition(@getBeginningOfCurrentWordBufferPosition()) moveToEndOfWord: -> - @setBufferPosition(@getEndOfCurrentWordBufferPosition()) + if position = @getEndOfCurrentWordBufferPosition() + @setBufferPosition(position) getBeginningOfCurrentWordBufferPosition: (options = {}) -> allowPrevious = options.allowPrevious ? true