mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add paths-searched event to the scan-handler
This allows the interface to know how many total paths were searched
This commit is contained in:
@@ -302,6 +302,10 @@ class Project
|
||||
task.on 'scan:result-found', (result) =>
|
||||
iterator(result)
|
||||
|
||||
if _.isFunction(options.onPathsSearched)
|
||||
task.on 'scan:paths-searched', (numberOfPathsSearched) ->
|
||||
options.onPathsSearched(numberOfPathsSearched)
|
||||
|
||||
deferred
|
||||
|
||||
# Private:
|
||||
|
||||
@@ -3,13 +3,23 @@
|
||||
module.exports = (rootPath, regexSource, options) ->
|
||||
callback = @async()
|
||||
|
||||
PATHS_COUNTER_SEARCHED_CHUNK = 50
|
||||
pathsSearched = 0
|
||||
|
||||
searcher = new PathSearcher()
|
||||
scanner = new PathScanner(rootPath, options)
|
||||
|
||||
searcher.on 'results-found', (result) ->
|
||||
emit('scan:result-found', result)
|
||||
|
||||
scanner.on 'path-found', ->
|
||||
pathsSearched++
|
||||
if pathsSearched % PATHS_COUNTER_SEARCHED_CHUNK == 0
|
||||
emit('scan:paths-searched', pathsSearched)
|
||||
|
||||
flags = "g"
|
||||
flags += "i" if options.ignoreCase
|
||||
regex = new RegExp(regexSource, flags)
|
||||
search regex, scanner, searcher, callback
|
||||
search regex, scanner, searcher, ->
|
||||
emit('scan:paths-searched', pathsSearched)
|
||||
callback()
|
||||
|
||||
Reference in New Issue
Block a user