Skip to content

textDocument/didClose is triggered upon the first close event when multiple views of the document are open #574

Closed

Description

@bzoracler

At least for the user-defined language server, when multiple views of a document are open, closing any one of them triggers a textDocument/didClose. I don't think this is correct.

The proper way to handle multiple open windows and textDocument/didClose is not explicitly described, but based on the discussion in microsoft/language-server-protocol#285 and the specifications, it is strongly implied that textDocument/didClose should only trigger when the last view of a document is closed, rather than the first time the user closes any one of the views.

In the current behaviour in LSP4IJ,

  • textDocument/didOpen only fires on the first time a user opens a document, not any subsequent times a user opens a new view for the document; it is therefore only possible to balance the number textDocument/didOpen events by triggering at most 1 textDocument/didClose while any views of the document is open. This is correct based on the specfication:

    textDocument/didOpen
    An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count for a particular textDocument is one.

  • If multiple views of a document are open, and textDocument/didClose triggers before all of them are closed, it is not possible to fulfil the following textDocument/didClose specification:

    textDocument/didClose
    The document’s master now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the master now exists on disk). As with the open notification the close notification is about managing the document’s content.

    This is because the client, at this point in time with opened views of the document, still owns the content.

Apart from triggering language server methods in textDocument/didClose too early, this issue also causes the language server to start shutting down when only one text document (with multiple views) is open, and you close any one of them.

Activity

  1. angelozerr commented on Oct 13, 2024

    @angelozerr
    Contributor

    At least for the user-defined language server, when multiple views of a document are open

    I dont master IntelliJ, could you explain me how you do that please (with wich menu)

  2. bzoracler commented on Oct 13, 2024

    @bzoracler
    ContributorAuthor

    There might be other ways of doing this, but I always use split views:

    image

    Right-click the file bar for the file you want to get another view for (here, manager.py) to get the menu shown, then choose either Split Right or Split Down. This will open another view of the file.

  3. angelozerr commented on Oct 13, 2024

    @angelozerr
    Contributor

    Thanks @bzoracler

  4. added a commit that references this issue on Oct 13, 2024
    7bbeb6a
  5. added this to the 0.7.0 milestone on Oct 13, 2024
  6. self-assigned this
    on Oct 13, 2024
  7. added
    bug
    on Oct 13, 2024
  8. added a commit that references this issue on Oct 13, 2024
    8f506b6
  9. angelozerr commented on Oct 13, 2024

    @angelozerr
    Contributor

    Please give a try to the latest nightly build, it should fix your issue, if no please reopen the issue.

    See https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds for more information with nightly build.

    The 0.7.0 will be released Tuesday, see #572

  10. bzoracler commented on Oct 13, 2024

    @bzoracler
    ContributorAuthor

    Thanks for the fast response, this worked perfectly!

  11. added a commit that references this issue on Oct 13, 2024
    e3f7ef4
  12. angelozerr commented on Oct 14, 2024

    @angelozerr
    Contributor

    OK great. Thanks for having reported the issue and give me feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions