From 27341f8f03573a9bf43230601747b562582b8a31 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 2 May 2021 01:36:33 -0500 Subject: [PATCH] fix: skip tracking the changes if maxFileCount is hit --- lib/paths-cache.js | 11 ++++++++++- lib/utils.js | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/paths-cache.js b/lib/paths-cache.js index 998c3cf..48348a2 100644 --- a/lib/paths-cache.js +++ b/lib/paths-cache.js @@ -3,7 +3,7 @@ import { EventEmitter } from "events" import minimatch from "minimatch" import { Directory, File } from "atom" import { dirname, basename } from "path" -import { union } from "./utils" +import { union, dedent } from "./utils" import { globifyPath, globifyDirectory, globifyGitIgnoreFile } from "globify-gitignore" import glob from "fast-glob" import * as chokidar from "chokidar" @@ -175,6 +175,15 @@ export default class PathsCache extends EventEmitter { } // add a watcher to run `this._onDirectoryChanged` const projectPath = projectDirectory.getPath() + if (this._filePathsByProjectDirectory.get(projectPath).length >= this.config.maxFileCount) { + console.warn(dedent`autocomplete-paths: Maximum file count of ${this.config.maxFileCount} has been exceeded, + so the subequent changes in the project are not tracked. + See these link to learn more: + https://github.com/atom-community/autocomplete-paths/wiki/Troubleshooting#maximum-file-limit-exceeded + https://github.com/atom-community/autocomplete-paths/issues/270 + `) + return + } const ignored = this._allIgnoredGlobByDirectory.get(projectDirectory.path) // TODO smarter handling of directory changes // TODO get paths from the watcher itself diff --git a/lib/utils.js b/lib/utils.js index b7cd35b..5d33496 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -26,3 +26,8 @@ export function union(arr1: Array, arr2: Array) { merge(arr1, arr2) return unique(arr1) } + +/** @params {Array} str */ +export function dedent(str) { + return String(str).replace(/(\n)\s+/g, "$1") +}