Open heejaechang opened 7 months ago
I think this might be a VS code issue.
We get this during find all references for a file that isn't open:
2024-04-18 16:26:11.415 [info] [Trace - 4:26:11 PM] Sending notification 'textDocument/didOpen'.
2024-04-18 16:26:11.415 [info] Params: {"textDocument":{"uri":"file:///c%3A/Users/rchiodo/source/repos/pylance-release/testing/single/src/lib/__init__.py","languageId":"python","version":1,"text":"# this file conatins references used by other test files.\r\n\r\nfrom findallreferences import FindConstructor\r\n\r\n# object instantiation reference\r\nFindConstructor()\r\n\r\nxx"}}
Which then causes us to show diagnostics for a file that isn't open.
I can reproduce this with typescript code too. It's not just python.
See this: https://github.com/microsoft/vscode/issues/205790
It seems we need to switch to a pull model if we want this to work correctly. It has to do with hidden tabs.
In fact the documentation for pull mentions that textDocument/didOpen didClose are not a consistent method to actually tell what files are visible in the editor:
Did open specifically says this:
DidOpenTextDocument Notification (:arrow_right:) The document open notification is sent from the client to the server to signal newly opened text documents. The document’s content is now managed by the client and the server must not try to read the document’s content using the document’s Uri. Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor.
Switching to a pull method can sort of work, but I believe there's a bug in vscode-language-client: https://github.com/microsoft/vscode-languageserver-node/issues/1464
single
folder invscode
FAR
onPath
- https://github.com/microsoft/pylance-release/blob/main/testing/single/src/findallreferences.py#L6Expected: diagnostics are cleared as new file is opened and old files are automatically closed. Actual: diagnostics are left in problems tab for long time (but it eventually goes away)
...
this repro with
2023.12.1
so must be existing bug.it eventually goes away so it could be a perf issue. (such as even if a file is closed, we don't cancel pending request such as semantic token or checker requests running in BG so BG is staled or something like that)