mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Bugfix: move-to-beginning-of-word no longer raises an error at position [0, 0]
This commit is contained in:
@@ -417,6 +417,10 @@ describe "Editor", ->
|
||||
expect(cursor2.getBufferPosition()).toEqual [1, 11]
|
||||
expect(cursor3.getBufferPosition()).toEqual [2, 39]
|
||||
|
||||
it "does not fail at position [0, 0]", ->
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
editor.trigger 'move-to-beginning-of-word'
|
||||
|
||||
describe "move-to-end-of-word", ->
|
||||
it "moves the cursor to the end of the word", ->
|
||||
editor.setCursorBufferPosition [0, 6]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user