-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Describe the Bug
When initializing Pyrefly config with publishDiagnostics and versionSupport set to true, I think published diagnostics should return the version key in the response in order to be able to track and match the published diagnostics with the version of the document, in case it is rapidly changing.
I am not sure if this is strictly what the specification dictates, as it is a bit vague in this area. However, that's how it's been working on Pyright.
The reason it's important to me is to be able to "discard" outdated diagnostics with an old version in case they are returned after a new version is published.
e.g.
"publishDiagnostics": {
"versionSupport": True,
"tagSupport": {
"valueSet": [
lsp_types.DiagnosticTag.Unnecessary,
lsp_types.DiagnosticTag.Deprecated,
]
},
}Also, pass the document versions during the textDocument/didChange event:
{
"textDocument": {
"uri": self._document_uri,
"version": self._document_version,
},
"contentChanges": [{"text": code}],
}Response from Pyrefly:
DEBUG lsp-types:process.py:281 Server -> Client: {'jsonrpc': '2.0', 'method': 'textDocument/publishDiagnostics', 'params': {'diagnostics': [], 'uri': 'file:///test.py'}}
Same code prepared against basedpyright returns the version appropriately:
DEBUG lsp-types:process.py:281 Server -> Client: {'jsonrpc': '2.0', 'method': 'textDocument/publishDiagnostics', 'params': {'uri': 'file:///test.py', 'version': 2, 'diagnostics': []}}
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response