Skip to content

Commit c8107c7

Browse files
committed
Fix multi-document edits dropping diagnostics
1 parent 7c62f01 commit c8107c7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/DiagnosticCollection.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type OnigScanner = vscodeOniguruma.OnigScanner & {
3030

3131
const activeDocuments: {
3232
[uriString: string]: {
33+
document: vscode.TextDocument;
3334
countDown: number;
3435
timeout: NodeJS.Timeout | number | undefined; // VSCode vs VSCode Web;
3536
};
@@ -69,10 +70,12 @@ export function debouncedDiagnostics(document: vscode.TextDocument) {
6970

7071
// https://github.com/microsoft/vscode/issues/11487
7172
const uriString = document.uri.toString();
72-
const activeDocument = activeDocuments[uriString] = activeDocuments[uriString] ?? {
73+
const activeDocument: typeof activeDocuments[string] = activeDocuments[uriString] = activeDocuments[uriString] ?? {
74+
document: document,
7375
countDown: 0,
7476
timeout: undefined,
7577
};
78+
activeDocument.document = document;
7679
activeDocument.countDown++; // waits longer the more edits there are
7780

7881
// Debounce recently repeated requests
@@ -85,7 +88,7 @@ export function debouncedDiagnostics(document: vscode.TextDocument) {
8588

8689
if (activeDocument.countDown < 0) {
8790
clearInterval(activeDocument.timeout); // timeout.refresh() doesn't work in VSCode web
88-
await Diagnostics(document);
91+
await Diagnostics(activeDocument.document);
8992
activeDocument.timeout = undefined;
9093
}
9194

0 commit comments

Comments
 (0)