Bugfix: move-to-beginning-of-word no longer raises an error at position [0, 0]

This commit is contained in:
Nathan Sobo
2012-04-09 13:59:46 -06:00
parent f3372f08de
commit cc52ff6f28
2 changed files with 10 additions and 7 deletions

View File

@@ -101,15 +101,14 @@ class Cursor extends View
getBeginningOfCurrentWordBufferPosition: (options = {}) ->
allowPrevious = options.allowPrevious ? true
position = null
bufferPosition = @getBufferPosition()
range = [[0,0], bufferPosition]
currentBufferPosition = @getBufferPosition()
beginningOfWordPosition = currentBufferPosition
range = [[0,0], currentBufferPosition]
@editor.backwardsTraverseRegexMatchesInRange @wordRegex, range, (match, matchRange, { stop }) =>
position = matchRange.start
if not allowPrevious and matchRange.end.isLessThan(bufferPosition)
position = bufferPosition
if matchRange.end.isGreaterThanOrEqual(currentBufferPosition) or allowPrevious
beginningOfWordPosition = matchRange.start
stop()
position
beginningOfWordPosition
getEndOfCurrentWordBufferPosition: (options = {}) ->
allowNext = options.allowNext ? true