Skip to content

Commit 185c3a8

Browse files
authored
perf: skip diagnostic update event on no changes (typescript-language-server#867)
1 parent 291afb3 commit 185c3a8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/diagnostic-queue.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class FileDiagnostics {
2727
) { }
2828

2929
public update(kind: DiagnosticKind, diagnostics: ts.server.protocol.Diagnostic[]): void {
30+
if (this.diagnosticsPerKind.get(kind)?.length === 0 && diagnostics.length === 0) {
31+
return;
32+
}
33+
3034
this.diagnosticsPerKind.set(kind, diagnostics);
3135
this.firePublishDiagnostics();
3236
}
@@ -87,6 +91,7 @@ export class DiagnosticEventQueue {
8791
if (this.ignoredDiagnosticCodes.size) {
8892
diagnostics = diagnostics.filter(diagnostic => !this.isDiagnosticIgnored(diagnostic));
8993
}
94+
9095
const uri = this.client.toResourceUri(file);
9196
const diagnosticsForFile = this.diagnostics.get(uri) || new FileDiagnostics(uri, this.publishDiagnostics, this.client, this.features);
9297
diagnosticsForFile.update(kind, diagnostics);

0 commit comments

Comments
 (0)