Skip to content

Commit

Permalink
fix: cache ignored glob by directory
Browse files Browse the repository at this point in the history
Using a unified array causes bugs in multi-project sessions
  • Loading branch information
aminya committed Apr 28, 2021
1 parent d59124f commit f619651
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/paths-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class PathsCache extends EventEmitter {
this._filePathsByProjectDirectory = new Map()
this._filePathsByDirectory = new Map()
this._fileWatchersByDirectory = new Map()
this._allIgnoredGlob = []
this._allIgnoredGlobByDirectory = new Map()
this.updateConfig()
}

Expand Down Expand Up @@ -175,7 +175,7 @@ export default class PathsCache extends EventEmitter {
}
// add a watcher to run `this._onDirectoryChanged`
const projectPath = projectDirectory.getPath()
const ignored = this._allIgnoredGlob
const ignored = this._allIgnoredGlobByDirectory.get(projectDirectory.path)
// TODO smarter handling of directory changes
// TODO get paths from the watcher itself
// TODO track gitignore file
Expand Down Expand Up @@ -483,9 +483,10 @@ export default class PathsCache extends EventEmitter {
*/
async _cachePathsForDirectoryWithGlob(directoryPath) {
const directoryGlob = globifyDirectory(directoryPath)
this._allIgnoredGlob = await this._getAllIgnoredGlob(directoryPath)
const allIgnoredGlob = await this._getAllIgnoredGlob(directoryPath)
this._allIgnoredGlobByDirectory.set(directoryPath, allIgnoredGlob)
const files = await glob(
[directoryGlob, ...this._allIgnoredGlob],
[directoryGlob, ...allIgnoredGlob],
// glob options
{
dot: true,
Expand Down

0 comments on commit f619651

Please sign in to comment.