From 8f77211f049ce60ea176c77d8e0982f7e2c4de8b Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Wed, 9 May 2012 12:18:37 -0700 Subject: [PATCH] Cursor.getBeginningOfCurrentWordBufferPosition only uses the previous 2 lines for its scan range. previous: editor.9000-line-file.at-end.move-to-beginning-of-word: 4695 / 100 = 46.95ms new: editor.9000-line-file.at-end.move-to-beginning-of-word: 1618 / 100 = 16.18ms --- src/app/cursor.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 25689f589..408efc0cb 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -106,12 +106,16 @@ class Cursor extends View getBeginningOfCurrentWordBufferPosition: (options = {}) -> allowPrevious = options.allowPrevious ? true currentBufferPosition = @getBufferPosition() + + previousRow = Math.max(0, currentBufferPosition.row - 1) + previousLinesRange = [[previousRow, 0], currentBufferPosition] beginningOfWordPosition = currentBufferPosition - range = [[0,0], currentBufferPosition] - @editor.backwardsScanInRange @wordRegex, range, (match, matchRange, { stop }) => + + @editor.backwardsScanInRange @wordRegex, previousLinesRange, (match, matchRange, { stop }) => if matchRange.end.isGreaterThanOrEqual(currentBufferPosition) or allowPrevious beginningOfWordPosition = matchRange.start stop() + beginningOfWordPosition getEndOfCurrentWordBufferPosition: (options = {}) ->