-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Summary
Diagnostics with DiagnosticTag.Unnecessary are not persisted across closing and reopening a file if a different buffer is viewed in between.
Description
Steps to reproduce:
- Install the FlatBuffers extension.
- Create and save a FlatBuffers file
foo.fbs:
table Foo {
f: int (deprecated);
}
- Observe a "Deprecated" diagnostic on the second line.
- Close
foo.fbs. - Open a different buffer (e.g. Zed log).
- Reopen
foo.fbs.
Expected Behavior: The "Deprecated" diagnostic should still be present despite the language server not republishing the unchanged diagnostics. This behavior would be consistent with how Warning diagnostics are persisted (e.g. if you delete the semicolon, close, and reopen).
Actual Behavior: It is not present until the file's diagnostics change and are republished.
video example
unnecessary-diagnostic-compress.mp4
language server logs from the above video
The main methods of interest are the two textDocument/publishDiagnostics. They never pass an empty diagnostics array.
I maintain the FlatBuffers extension/LS, but I am reporting it since I think this behavior might affect other extensions. My interpretation of the following section of the LSP spec is that the client should cache diagnostics until the server clears them:
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.
I tried to reproduce this with other extensions (lua, basedpyright) but they either use pull diagnostics or republish diagnostics on textDocument/didOpen which masks the problem.
VSCode does persist unnecessary diagnostics across file closure.
Zed Version and System Specs
Zed: v0.211.3 (Zed Preview)
OS: macOS 14.7.1
Memory: 64 GiB
Architecture: aarch64