Skip to content

Refresh config file diagnostics when a config file is saved - #4739

Open
UditDewan wants to merge 1 commit into
microsoft:mainfrom
UditDewan:fix/config-diagnostics-on-save
Open

Refresh config file diagnostics when a config file is saved#4739
UditDewan wants to merge 1 commit into
microsoft:mainfrom
UditDewan:fix/config-diagnostics-on-save

Conversation

@UditDewan

Copy link
Copy Markdown
Contributor

Fixes #4713.

Problem

Diagnostics for tsconfig.json / jsconfig.json are push-only: they are published from publishProgramDiagnostics as part of a snapshot update. DidChangeFile and DidSaveFile only append to pendingFileChanges; neither schedules a snapshot update.

For a normal source file that is fine, because the client follows an edit with requests (diagnostic pulls, completions, …) that flush the pending changes. Editing a config file usually isn't followed by any request, so the edit sits in the pending queue and the config file keeps showing its old diagnostics until something unrelated happens to flush it.

Repro from the issue: open a .ts file, open tsconfig.json, set "target": "es5", save — no Option 'target=ES5' has been removed. diagnostic appears, where 6.0 reports one.

Fix

DidSaveFile schedules a (debounced) snapshot update when the saved file is a config file, which flushes the pending edit and republishes the config file's diagnostics. Config files are recognized by base name (including customConfigFileName) or by being present in the snapshot's ConfigFileRegistry, which also covers configs pulled in through extends / project references under a non-standard name.

Non-config saves are unchanged, so this adds no work to the common save path.

Tests

Added TestPushDiagnostics/updates diagnostics when an open config file is saved: opens a config file, changes target to es5, saves, and asserts the diagnostic is published with no intervening request. It fails on main (no diagnostics published) and passes with this change.


This change was authored with AI assistance. I picked the issue, reviewed and tested the patch myself, and will handle review feedback.

Diagnostics for tsconfig/jsconfig files are only published as part of a
snapshot update. Saving an edited config file left the change pending until
some unrelated request happened to flush it, so the config file's diagnostics
went stale.

Schedule a snapshot update when a saved file is a config file.

Fixes microsoft#4713
Copilot AI review requested due to automatic review settings July 25, 2026 04:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

return true
}
// Configs pulled in by `extends` or project references can be named anything.
return snapshot.ConfigFileRegistry.GetConfig(snapshot.toPath(fileName)) != nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsconfig/jsconfig diagnostic doesn't refresh after file saved

2 participants