From 4ee88c5de7db414c464167b241a20c4fd161f54b Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Sat, 14 Sep 2024 16:48:07 -0400 Subject: [PATCH] Add longer grace period for diagnostics to catch up when existing errors should have been fixed by claude --- src/integrations/DiagnosticsMonitor.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/integrations/DiagnosticsMonitor.ts b/src/integrations/DiagnosticsMonitor.ts index 2e6cd1b..7c1ff34 100644 --- a/src/integrations/DiagnosticsMonitor.ts +++ b/src/integrations/DiagnosticsMonitor.ts @@ -58,10 +58,23 @@ class DiagnosticsMonitor { return currentDiagnostics } - return this.waitForUpdatedDiagnostics() + let timeout = 300 + + // if diagnostics contain existing errors (since the check above didn't trigger) then it's likely claude just did something that should have fixed the error, so we'll give a longer grace period for diagnostics to catch up + const hasErrorsOrWarnings = currentDiagnostics.some(([_, diagnostics]) => + diagnostics.some( + (d) => + d.severity === vscode.DiagnosticSeverity.Error || d.severity === vscode.DiagnosticSeverity.Warning + ) + ) + if (hasErrorsOrWarnings) { + timeout = 5_000 + } + + return this.waitForUpdatedDiagnostics(timeout) } - private async waitForUpdatedDiagnostics(timeout: number = 300): Promise { + private async waitForUpdatedDiagnostics(timeout: number): Promise { return new Promise((resolve, reject) => { const timer = setTimeout(() => { cleanup()