mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
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
This commit is contained in:
@@ -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 = {}) ->
|
||||
|
||||
Reference in New Issue
Block a user