mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-28 09:01:33 +03:00
parent
c424f7bafa
commit
1f30231d5c
@ -429,3 +429,16 @@ describe "Project", ->
|
||||
|
||||
runs ->
|
||||
expect(resultHandler).not.toHaveBeenCalled()
|
||||
|
||||
it "scans buffer contents if the buffer is modified", ->
|
||||
editSession = project.openSync("a")
|
||||
editSession.setText("Elephant")
|
||||
results = []
|
||||
waitsForPromise ->
|
||||
project.scan /a|Elephant/, (result) -> results.push result
|
||||
|
||||
runs ->
|
||||
expect(results).toHaveLength 3
|
||||
resultForA = _.find results, ({filePath}) -> path.basename(filePath) == 'a'
|
||||
expect(resultForA.matches).toHaveLength 1
|
||||
expect(resultForA.matches[0].matchText).toBe 'Elephant'
|
||||
|
@ -218,6 +218,11 @@ class Project
|
||||
getBuffers: ->
|
||||
new Array(@buffers...)
|
||||
|
||||
isPathModified: (filePath) ->
|
||||
absoluteFilePath = @resolve(filePath)
|
||||
existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath
|
||||
existingBuffer?.isModified()
|
||||
|
||||
# Private: Only to be used in specs
|
||||
bufferForPathSync: (filePath, text) ->
|
||||
absoluteFilePath = @resolve(filePath)
|
||||
@ -315,12 +320,18 @@ class Project
|
||||
deferred.resolve()
|
||||
|
||||
task.on 'scan:result-found', (result) =>
|
||||
iterator(result)
|
||||
iterator(result) unless @isPathModified(result.filePath)
|
||||
|
||||
if _.isFunction(options.onPathsSearched)
|
||||
task.on 'scan:paths-searched', (numberOfPathsSearched) ->
|
||||
options.onPathsSearched(numberOfPathsSearched)
|
||||
|
||||
for buffer in @buffers when buffer.isModified()
|
||||
filePath = buffer.getPath()
|
||||
matches = []
|
||||
buffer.scan regex, (match) -> matches.push match
|
||||
iterator {filePath, matches} if matches.length > 0
|
||||
|
||||
deferred.promise
|
||||
|
||||
# Private:
|
||||
|
Loading…
Reference in New Issue
Block a user