mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-29 01:27:00 +03:00
parent
c424f7bafa
commit
1f30231d5c
@ -429,3 +429,16 @@ describe "Project", ->
|
|||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(resultHandler).not.toHaveBeenCalled()
|
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: ->
|
getBuffers: ->
|
||||||
new Array(@buffers...)
|
new Array(@buffers...)
|
||||||
|
|
||||||
|
isPathModified: (filePath) ->
|
||||||
|
absoluteFilePath = @resolve(filePath)
|
||||||
|
existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath
|
||||||
|
existingBuffer?.isModified()
|
||||||
|
|
||||||
# Private: Only to be used in specs
|
# Private: Only to be used in specs
|
||||||
bufferForPathSync: (filePath, text) ->
|
bufferForPathSync: (filePath, text) ->
|
||||||
absoluteFilePath = @resolve(filePath)
|
absoluteFilePath = @resolve(filePath)
|
||||||
@ -315,12 +320,18 @@ class Project
|
|||||||
deferred.resolve()
|
deferred.resolve()
|
||||||
|
|
||||||
task.on 'scan:result-found', (result) =>
|
task.on 'scan:result-found', (result) =>
|
||||||
iterator(result)
|
iterator(result) unless @isPathModified(result.filePath)
|
||||||
|
|
||||||
if _.isFunction(options.onPathsSearched)
|
if _.isFunction(options.onPathsSearched)
|
||||||
task.on 'scan:paths-searched', (numberOfPathsSearched) ->
|
task.on 'scan:paths-searched', (numberOfPathsSearched) ->
|
||||||
options.onPathsSearched(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
|
deferred.promise
|
||||||
|
|
||||||
# Private:
|
# Private:
|
||||||
|
Loading…
Reference in New Issue
Block a user