Skip to content

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

Closed

Description

@DanTup

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

Activity

  1. DanTup commented on Nov 3, 2020

    @DanTup
    ContributorAuthor

    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?

  2. dbaeumer commented on Nov 3, 2020

    @dbaeumer
    Member

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

  3. added
    *as-designed
    on Nov 4, 2020
  4. jrieken commented on Nov 4, 2020

    @jrieken
    Contributor
  5. locked and limited conversation to collaborators on Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*as-designed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions