question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignore onDidOpenTextDocument+onDidCloseTextDocument that fire together when showing definition hover previews

See original GitHub issue

VS 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:open
  • Created 3 years ago
  • Reactions:3
  • Comments:21 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
dbaeumercommented, Sep 24, 2021

Virtual text documents for embedded languages is one example.

1reaction
DanTupcommented, Nov 3, 2020

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” 😔

Read more comments on GitHub >

github_iconTop Results From Across the Web

No way to interact with definition hover preview #13402 - GitHub
Definition previews for a symbol (shown when holding ⌘ on hover) can also show up in the hover widget in a scrollable cell....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found