Merge from vscode e558dc6ea73a75bd69d7a0b485f0e7e4194c66bf (#6864)

This commit is contained in:
Anthony Dresser
2019-08-21 20:44:59 -07:00
committed by GitHub
parent d2ae0f0154
commit 985bfae8a0
107 changed files with 2260 additions and 814 deletions

View File

@@ -76,16 +76,27 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Promise
return done(results);
}
if (token.count > MAX_FILES) {
token.count += files.length;
token.maxReached = true;
return done(results);
}
let pending = files.length;
if (pending === 0) {
return done(results);
}
for (const file of files) {
if (token.maxReached) {
return done(results);
}
let filesToRead = files;
if (token.count + files.length > MAX_FILES) {
token.maxReached = true;
pending = MAX_FILES - token.count;
filesToRead = files.slice(0, pending);
}
token.count += files.length;
for (const file of filesToRead) {
stat(join(dir, file), (err, stats) => {
// Ignore files that can't be read
if (err) {
@@ -108,11 +119,6 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Promise
}
}
} else {
if (token.count >= MAX_FILES) {
token.maxReached = true;
}
token.count++;
results.push(file);
if (--pending === 0) {