mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-19 16:18:58 +01:00
* fix #124276 batch markdown file requests
* cleanup and modify return type
* Revert "cleanup and modify return type"
This reverts commit 62d62b4947.
* cleanup getAllMarkdownDocuments
* fix markdown batching
* fix var not being modified
cleanup function call
remove modulo use
* don't create a new array on each iteration
Co-authored-by: Matt Bierner <matb@microsoft.com>
This commit is contained in:
@@ -28,10 +28,23 @@ class VSCodeWorkspaceMarkdownDocumentProvider extends Disposable implements Work
|
||||
|
||||
private readonly utf8Decoder = new TextDecoder('utf-8');
|
||||
|
||||
async getAllMarkdownDocuments() {
|
||||
/**
|
||||
* Reads and parses all .md documents in the workspace.
|
||||
* Files are processed in batches, to keep the number of open files small.
|
||||
*
|
||||
* @returns Array of processed .md files.
|
||||
*/
|
||||
async getAllMarkdownDocuments(): Promise<SkinnyTextDocument[]> {
|
||||
const maxConcurrent = 20;
|
||||
const docList: SkinnyTextDocument[] = [];
|
||||
const resources = await vscode.workspace.findFiles('**/*.md', '**/node_modules/**');
|
||||
const docs = await Promise.all(resources.map(doc => this.getMarkdownDocument(doc)));
|
||||
return docs.filter(doc => !!doc) as SkinnyTextDocument[];
|
||||
|
||||
for (let i = 0; i < resources.length; i += maxConcurrent) {
|
||||
const resourceBatch = resources.slice(i, i + maxConcurrent);
|
||||
const documentBatch = (await Promise.all(resourceBatch.map(this.getMarkdownDocument))).filter((doc) => !!doc) as SkinnyTextDocument[];
|
||||
docList.push(...documentBatch);
|
||||
}
|
||||
return docList;
|
||||
}
|
||||
|
||||
public get onDidChangeMarkdownDocument() {
|
||||
|
||||
Reference in New Issue
Block a user