moveCursorToBeginningOfWord works when preceded by a blank line

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-10-30 12:05:46 -06:00
parent 46fc7f2375
commit 5b7e96067a
2 changed files with 7 additions and 2 deletions

View File

@@ -269,6 +269,11 @@ describe "EditSession", ->
editSession.setCursorBufferPosition([0, 0])
editSession.moveCursorToBeginningOfWord()
it "works when the preceding line is blank", ->
editSession.setCursorBufferPosition([10, 0])
editSession.moveCursorToBeginningOfWord()
expect(editSession.getCursorBufferPosition()).toEqual [9, 0]
describe ".moveCursorToEndOfWord()", ->
it "moves the cursor to the end of the word", ->
editSession.setCursorBufferPosition [0, 6]

View File

@@ -120,8 +120,8 @@ class Cursor
getBeginningOfCurrentWordBufferPosition: (options = {}) ->
allowPrevious = options.allowPrevious ? true
currentBufferPosition = @getBufferPosition()
previousRow = Math.max(0, currentBufferPosition.row - 1)
previousLinesRange = [[previousRow, 0], currentBufferPosition]
previousNonBlankRow = @editSession.buffer.previousNonBlankRow(currentBufferPosition.row)
previousLinesRange = [[previousNonBlankRow, 0], currentBufferPosition]
beginningOfWordPosition = currentBufferPosition
@editSession.backwardsScanInRange @wordRegex, previousLinesRange, (match, matchRange, { stop }) =>