Ignore onDidOpenTextDocument+onDidCloseTextDocument that fire together when showing definition hover previews
See original GitHub issueVS Code sends both onDidOpenTextDocument
and onDidCloseTextDocument
immediately together whenever it renders a preview of a document in a tooltip:
https://github.com/microsoft/vscode/issues/109908 https://github.com/microsoft/vscode/issues/84875
Apparently this is by design, but it results in the LSP client telling the server to open and then immediately close a document. This may trigger expensive work of analyzing a file that has not been opened by the user.
This was fixed by TypeScript in the client extension (https://github.com/microsoft/vscode/commit/fa72810c777c07b8589ca0495d343e057d180977). If that’s how this should be fixed, it seems like the LSP client will need the same workaround since there is no client code for us to implement ourselves this as LSP users.
(Honestly I think this would be better handled in VS Code, but since it’s been rejected I think it should be done here rather than in the LSP server, as it seems silly for LSP servers to be adding delays to work around VS Codes quirks).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:21 (19 by maintainers)
Top GitHub Comments
Virtual text documents for embedded languages is one example.
Understood. I had other ideas (like dropping the event if the document is not in the active editor list), but honestly everything feels like a bit of a hack because of limited/incompatible VS Code APIs. It’s kinda weird that “Ctrl+clicking a symbol has a delay” is blocked by “VS Code doesn’t have an API to know which files are open” 😔