fuzzy find files using content under cursor

This commit is contained in:
Derek Greentree
2013-01-17 15:36:22 -08:00
parent 2b9c768273
commit b229dd21f4
5 changed files with 84 additions and 5 deletions

View File

@@ -288,6 +288,7 @@ class Buffer
matchesInCharacterRange: (regex, startIndex, endIndex) ->
text = @getText()
matches = []
regex.lastIndex = startIndex

View File

@@ -150,7 +150,7 @@ class Cursor
previousLinesRange = [[previousNonBlankRow, 0], currentBufferPosition]
beginningOfWordPosition = currentBufferPosition
@editSession.backwardsScanInRange @wordRegex, previousLinesRange, (match, matchRange, { stop }) =>
@editSession.backwardsScanInRange (options.wordRegex || @wordRegex), previousLinesRange, (match, matchRange, { stop }) =>
if matchRange.end.isGreaterThanOrEqual(currentBufferPosition) or allowPrevious
beginningOfWordPosition = matchRange.start
stop()
@@ -162,7 +162,7 @@ class Cursor
range = [currentBufferPosition, @editSession.getEofBufferPosition()]
endOfWordPosition = null
@editSession.scanInRange @wordRegex, range, (match, matchRange, { stop }) =>
@editSession.scanInRange (options.wordRegex || @wordRegex), range, (match, matchRange, { stop }) =>
endOfWordPosition = matchRange.end
if not allowNext and matchRange.start.isGreaterThan(currentBufferPosition)
endOfWordPosition = currentBufferPosition
@@ -195,6 +195,14 @@ class Cursor
getCurrentWordPrefix: ->
@editSession.getTextInBufferRange([@getBeginningOfCurrentWordBufferPosition(), @getBufferPosition()])
getCurrentWord: (options = {}) ->
match = @editSession.getTextInBufferRange([@getBeginningOfCurrentWordBufferPosition(options),
@getEndOfCurrentWordBufferPosition(options)])
return match if options.includeDelimiter?
if match?.length > 2
match.substring(1, match.length-1)
isAtBeginningOfLine: ->
@getBufferPosition().column == 0