Repository navigation
fix: clear diagnostics when a document is closed - #152
Merged
jdesrosiers merged 6 commits intoOct 13, 2026
Merged
jdesrosiers merged 6 commits into
jdesrosiers merged 6 commits into
Conversation
Collaborator
|
Next time, please wait to be assigned before submitting PRs. |
jdesrosiers
force-pushed
the
fix/clear-diagnostics-on-close
branch
from
October 13, 2026 18:53
3644c52 to
536081b
Compare
jdesrosiers
approved these changes
Oct 13, 2026
jdesrosiers
left a comment
Collaborator
There was a problem hiding this comment.
I made an improvement to the TestClient so we don't have to do the 200ms wait. I also made a couple fixes for some edge cases.
The connection keeps only one handler per notification, so registering a PublishDiagnostics handler in a test silently replaced getDiagnostics' handler. TestClient now owns the single handler and fans out to listeners, and onDiagnostics lets tests observe every publish for a URI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checking only the URI let a run for a closed document through if the URI had been reopened, cancelling the new document's validation and publishing diagnostics for the old content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A throwing provider left its entry in pendingSends and escaped the handler as an unhandled rejection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hold the schema read so the validation is guaranteed to be in flight when the document closes, then assert the exact sequence of publishes instead of sleeping and checking only the last one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jdesrosiers
force-pushed
the
fix/clear-diagnostics-on-close
branch
from
October 13, 2026 18:59
536081b to
5c2319e
Compare
Contributor
Author
|
thankyou for merging @jdesrosiers, i got your points |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #150
What this fixes
When a document with syntax or schema errors was closed (
textDocument/didClose), the server never published an empty diagnostics list ({ uri, diagnostics: [] }). Stale diagnostics could stay in the editor's Problems panel after the file was closed.Changes
Diagnosticsnow subscribes tojsonDocuments.onDidClose. On close, it aborts any pending send for that document, removes its entry frompendingSends, and publishes{ uri, diagnostics: [] }.sendDiagnosticsis guarded so a validation that finishes after the document is closed doesn't publish diagnostics. It also skips starting validation for documents that are no longer open injsonDocuments.src/features/diagnostics/Diagnostics.test.ts, covering:Testing
tsc --noEmit) and lint (oxlint src) pass.Notes