Fixes and 💄 around maxResults for search providers

This commit is contained in:
Rob Lourens
2018-05-26 12:19:40 -07:00
parent 284759e356
commit 4eaf58348b
4 changed files with 141 additions and 58 deletions

View File

@@ -401,13 +401,15 @@ class TextSearchEngine {
return;
}
this.resultCount++;
this.collector.add(match, folderIdx);
if (this.resultCount >= this.config.maxResults) {
this.isLimitHit = true;
this.cancel();
}
if (!this.isLimitHit) {
this.resultCount++;
this.collector.add(match, folderIdx);
}
};
// For each root folder
@@ -492,7 +494,8 @@ class TextSearchEngine {
includes,
useIgnoreFiles: !this.config.disregardIgnoreFiles,
followSymlinks: !this.config.ignoreSymlinks,
encoding: this.config.fileEncoding
encoding: this.config.fileEncoding,
maxFileSize: this.config.maxFileSize
};
}
}
@@ -589,7 +592,7 @@ class FileSearchEngine {
PPromise.join(folderQueries.map(fq => {
return this.searchInFolder(fq).then(null, null, onResult);
})).then(() => {
resolve({ isLimitHit: false });
resolve({ isLimitHit: this.isLimitHit });
}, (errs: Error[]) => {
const errMsg = errs
.map(err => toErrorMessage(err))