Only compute diagnostics for opened md files (#153395)

* Only compute diagnostics for opened md files

For #152494

* Make tests stable for result ordering
This commit is contained in:
Matt Bierner
2022-06-27 15:55:38 -07:00
committed by GitHub
parent 87e684ef9b
commit e13feea6ae
9 changed files with 91 additions and 40 deletions

View File

@@ -143,6 +143,16 @@ export class MdWorkspaceInfoCache<T> extends Disposable {
return Array.from(await this._cache.entries(), x => x[1]);
}
public async getForDocs(docs: readonly ITextDocument[]): Promise<T[]> {
for (const doc of docs) {
if (!this._cache.has(doc.uri)) {
this.update(doc);
}
}
return Promise.all(docs.map(doc => this._cache.get(doc.uri) as Promise<T>));
}
private async ensureInit(): Promise<void> {
if (!this._init) {
this._init = this.populateCache();
@@ -157,7 +167,9 @@ export class MdWorkspaceInfoCache<T> extends Disposable {
private async populateCache(): Promise<void> {
const markdownDocumentUris = await this.workspace.getAllMarkdownDocuments();
for (const document of markdownDocumentUris) {
this.update(document);
if (!this._cache.has(document.uri)) {
this.update(document);
}
}
}