Fix exception when moving to the end of word when there *is* no word

This commit is contained in:
Nathan Sobo 2012-11-26 15:12:21 -07:00
parent 06e281321b
commit bf9a7cc9a1
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -130,7 +130,8 @@ class Cursor
@setBufferPosition(@getBeginningOfCurrentWordBufferPosition())
moveToEndOfWord: ->
@setBufferPosition(@getEndOfCurrentWordBufferPosition())
if position = @getEndOfCurrentWordBufferPosition()
@setBufferPosition(position)
getBeginningOfCurrentWordBufferPosition: (options = {}) ->
allowPrevious = options.allowPrevious ? true