Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDidOpenTextDocument+onDidCloseTextDocument both fire together when holding Cmd while hovering #109908

Closed
DanTup opened this issue Nov 3, 2020 · 3 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@DanTup
Copy link
Contributor

DanTup commented Nov 3, 2020

When you hover over a symbol and hold Ctrl/Cmd, VS Code sends a definition request to include a preview in the tooltip. However it also onDidOpenTextDocument followed immediately by onDidCloseTextDocument for the document that contains the definition for apparently no reason.

This results in the language server being told a file has been opened (that has not) and may kick off expensive analysis work, only to immediately be told the file is closed. The open/close events occur immediately together, so it appears VS Code is getting no benefit or information from this at all, it's only potentially triggering unnecessary work on the server.

Here's a repro:

https://github.com/DanTup/vscode-repro-ctrl-hover

This simply provides a basic definition provider and los when open/close is called. When you run it, it'll open the sample_project folder that has two text files. Open one.txt and hover over the text then press/hold Cmd/Ctrl. Each time you press Cmd/Ctrl you'll see in the debug console the Open/Close events fired.

Nov-03-2020 11-11-47

In some cases (I haven't fully debugged yet), VS code actually seems to trigger a bunch of requests and cancel them. The original log where I noticed the behaviour above shows a number of requests all being sent to the LSP server at exactly the same time (before any are responded to), many of which are cancelled:

Screenshot 2020-11-03 at 10 30 09

@DanTup
Copy link
Contributor Author

DanTup commented Nov 3, 2020

Apparently this has come up before in #84875 and was just fixed in the TS extension. If this isn't going to be fixed by VS Code, it seems like the LSP language client is going to need the same workaround?

@dbaeumer
Copy link
Member

dbaeumer commented Nov 3, 2020

A proper fix for this would require addressing #15178. Otherwise even batching is only a band aid

@jrieken jrieken added the *as-designed Described behavior is as designed label Nov 4, 2020
@jrieken
Copy link
Member

jrieken commented Nov 4, 2020

What @dbaeumer says

@jrieken jrieken closed this as completed Nov 4, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

4 participants