Skip to content

Commit 5c6d0ab

Browse files
authored
Merge pull request #272 from atom-community/skip-tracking
fix: skip tracking the changes if maxFileCount is hit
2 parents f446940 + 27341f8 commit 5c6d0ab

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/paths-cache.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { EventEmitter } from "events"
33
import minimatch from "minimatch"
44
import { Directory, File } from "atom"
55
import { dirname, basename } from "path"
6-
import { union } from "./utils"
6+
import { union, dedent } from "./utils"
77
import { globifyPath, globifyDirectory, globifyGitIgnoreFile } from "globify-gitignore"
88
import glob from "fast-glob"
99
import * as chokidar from "chokidar"
@@ -175,6 +175,15 @@ export default class PathsCache extends EventEmitter {
175175
}
176176
// add a watcher to run `this._onDirectoryChanged`
177177
const projectPath = projectDirectory.getPath()
178+
if (this._filePathsByProjectDirectory.get(projectPath).length >= this.config.maxFileCount) {
179+
console.warn(dedent`autocomplete-paths: Maximum file count of ${this.config.maxFileCount} has been exceeded,
180+
so the subequent changes in the project are not tracked.
181+
See these link to learn more:
182+
https://github.com/atom-community/autocomplete-paths/wiki/Troubleshooting#maximum-file-limit-exceeded
183+
https://github.com/atom-community/autocomplete-paths/issues/270
184+
`)
185+
return
186+
}
178187
const ignored = this._allIgnoredGlobByDirectory.get(projectDirectory.path)
179188
// TODO smarter handling of directory changes
180189
// TODO get paths from the watcher itself

lib/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ export function union(arr1: Array<any>, arr2: Array<any>) {
2626
merge(arr1, arr2)
2727
return unique(arr1)
2828
}
29+
30+
/** @params {Array<string>} str */
31+
export function dedent(str) {
32+
return String(str).replace(/(\n)\s+/g, "$1")
33+
}

0 commit comments

Comments
 (0)