Two things:

* Removed the `Directory` argument to `didSearchPaths`.
Now each searcher gets its own instance of `didSearchPaths` that is parameterized by provider.
* Simplified `DefaultDirectorySearcher.search()` so it creates one `DirectorySearch`
rather than one per `Directory` passed to `search()`.
This commit is contained in:
Michael Bolin
2015-06-03 23:29:56 -04:00
parent 18ac7d0cbc
commit 0630bce95c
3 changed files with 29 additions and 34 deletions

View File

@@ -831,32 +831,30 @@ class Workspace extends Model
onPathsSearchedOption = options.onPathsSearched
totalNumberOfPathsSearched = 0
numberOfPathsSearchedForDirectory = new Map()
onPathsSearched = (directory, numberOfPathsSearched) ->
oldValue = numberOfPathsSearchedForDirectory.get(directory)
onPathsSearched = (searcher, numberOfPathsSearched) ->
oldValue = numberOfPathsSearchedForDirectory.get(searcher)
if oldValue
totalNumberOfPathsSearched -= oldValue
numberOfPathsSearchedForDirectory.set(directory, numberOfPathsSearched)
numberOfPathsSearchedForDirectory.set(searcher, numberOfPathsSearched)
totalNumberOfPathsSearched += numberOfPathsSearched
onPathsSearchedOption(totalNumberOfPathsSearched)
else
onPathsSearched = ->
# Build up the options object that will be shared by all searchers.
searchOptions =
inclusions: options.paths or []
includeHidden: true
excludeVcsIgnores: atom.config.get('core.excludeVcsIgnoredPaths')
exclusions: atom.config.get('core.ignoredNames')
follow: atom.config.get('core.followSymlinks')
didMatch: (result) ->
iterator(result) unless atom.project.isPathModified(result.filePath)
didError: (error) ->
iterator(null, error)
didSearchPaths: onPathsSearched
# Kick off all of the searches and unify them into one Promise.
allSearches = []
directoriesForSearcher.forEach (directories, searcher) ->
searchOptions =
inclusions: options.paths or []
includeHidden: true
excludeVcsIgnores: atom.config.get('core.excludeVcsIgnoredPaths')
exclusions: atom.config.get('core.ignoredNames')
follow: atom.config.get('core.followSymlinks')
didMatch: (result) ->
iterator(result) unless atom.project.isPathModified(result.filePath)
didError: (error) ->
iterator(null, error)
didSearchPaths: (count) -> onPathsSearched(searcher, count)
directorySearcher = searcher.search(directories, regex, searchOptions)
allSearches.push(directorySearcher)
searchPromise = Promise.all(allSearches)