From f698d7e9dcff5c9aebef3064d7d9236ccdcd3c17 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 08:20:11 -0800 Subject: [PATCH] :lipstick: --- src/app/cursor.coffee | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 04d13ee37..659e91e43 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -155,16 +155,16 @@ class Cursor allowPrevious = options.allowPrevious ? true currentBufferPosition = @getBufferPosition() previousNonBlankRow = @editSession.buffer.previousNonBlankRow(currentBufferPosition.row) - previousLinesRange = [[previousNonBlankRow, 0], currentBufferPosition] + range = [[previousNonBlankRow, 0], currentBufferPosition] - beginningOfWordPosition = currentBufferPosition - - @editSession.backwardsScanInRange (options.wordRegex ? @wordRegExp()), previousLinesRange, (match, matchRange, { stop }) => + beginningOfWordPosition = null + @editSession.backwardsScanInRange (options.wordRegex ? @wordRegExp()), range, (match, matchRange, { stop }) => if matchRange.end.isGreaterThanOrEqual(currentBufferPosition) or allowPrevious beginningOfWordPosition = matchRange.start - stop() unless beginningOfWordPosition.isEqual(currentBufferPosition) + if not beginningOfWordPosition?.isEqual(currentBufferPosition) + stop() - beginningOfWordPosition + beginningOfWordPosition or currentBufferPosition getEndOfCurrentWordBufferPosition: (options = {}) -> allowNext = options.allowNext ? true @@ -172,14 +172,13 @@ class Cursor range = [currentBufferPosition, @editSession.getEofBufferPosition()] endOfWordPosition = null - @editSession.scanInRange (options.wordRegex ? @wordRegExp()), - range, (match, matchRange, { stop }) => + @editSession.scanInRange (options.wordRegex ? @wordRegExp()), range, (match, matchRange, { stop }) => endOfWordPosition = matchRange.end - return if endOfWordPosition.isEqual(currentBufferPosition) - - if not allowNext and matchRange.start.isGreaterThan(currentBufferPosition) + if matchRange.start.isGreaterThan(currentBufferPosition) and not allowNext endOfWordPosition = currentBufferPosition - stop() + if not endOfWordPosition.isEqual(currentBufferPosition) + stop() + endOfWordPosition or currentBufferPosition getCurrentWordBufferRange: (options={}) ->