f0db648cb6
9558: Do not erase Cargo diagnostics from the closed documents r=matklad a=SomeoneToIgnore Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6850 The LSP specification at https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_publishDiagnostics states that > Diagnostics notification are sent from the server to the client to signal results of validation runs. > > Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics: > > * if a language is single file only (for example HTML) then diagnostics are cleared by the server when the file is closed. > * if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache). > > When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. If the computed set is empty it has to push the empty array to clear former diagnostics. Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. So for projects we should not clear any diagnostics from cargo/json projects. Our "standalone file" mode is in a way a project too, with sysroot attached and a potential support for dynamic standalone files. Co-authored-by: Kirill Bulatov <mail4score@gmail.com> |
||
---|---|---|
.. | ||
base_db | ||
cfg | ||
flycheck | ||
hir | ||
hir_def | ||
hir_expand | ||
hir_ty | ||
ide | ||
ide_assists | ||
ide_completion | ||
ide_db | ||
ide_diagnostics | ||
ide_ssr | ||
limit | ||
mbe | ||
parser | ||
paths | ||
proc_macro_api | ||
proc_macro_srv | ||
proc_macro_test | ||
profile | ||
project_model | ||
rust-analyzer | ||
sourcegen | ||
stdx | ||
syntax | ||
test_utils | ||
text_edit | ||
toolchain | ||
tt | ||
vfs | ||
vfs-notify |