Skip to content

Multiple didOpen calls #285

Closed
Closed

Description

What is the expected behavior of sending multiple times didOpen for the same file?
I would prefer that calling didOpen on an already opened file would be supported. There are some cases where it simplifies the client flow.

Activity

  1. kdvolder commented on Aug 16, 2017

    @kdvolder

    My opinion... if didClose is called only once then didOpen should also be called only once. This relates to: atom/atom-languageclient#88

    I implemented a workaround for a bug to accomodate a misbehaving client which still works with a well-behaved client too. But this workaround will break if the client doesn't ballance its open/close counts. In other words, a correct implementation should not call open on something that already open and only call close once when it is closed. But... whatever you do... make sure the open/close counts are always balanced. Any sane server will assume that open/close calls are paired.

  2. amiramw commented on Aug 19, 2017

    @amiramw
    ContributorAuthor

    There are two ways balancing the open/close count. You can call multiple times to didOpen and multiple times to didClose and make sure they are balanced or you can call didOpen once on the first open and didClose once on the last close.
    I'm pretty sure most of the implementations are not handling correctly the first option and some of them are ignoring multiple didOpen after the first one.
    I guess the second option make sense. I would prefer the protocol to state the expected behavior.

  3. kdvolder commented on Aug 22, 2017

    @kdvolder

    You can call multiple times to didOpen and multiple times to didClose and make sure they are balanced

    That is not how I read the spec, but I know its how Atom does it at the moment.

    or you can call didOpen once on the first open and didClose once on the last close.

    I think that is how the spec intended it. I agree that the spec could be clearer on this, and probably a PR trying to clarify that point is a good idea. But there are some words about where the 'document truth' resides after a close that make it pretty clear that, after close is received there should be no more (possibly dirty) copies of the resource residing in editor memory. So I think that it is pretty clear a close event singnals the point in time where the last editor got closed.

    See here: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textDocument_didClose

    It says:

    The document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to ...

  4. dbaeumer commented on Oct 3, 2017

    @dbaeumer
    Member

    I see that the word open is misleading. From a protocol perspective it is more about ownership. When a document gets opened the ownership of the content goes to the tool. When the document gets closed the ownership goes back to the server.

    This being said there should only be one open call and one close call. Balancing them makes things more complicated IMO option and from a protocol perspective doesn't add any value. I will add a sentence to clarify this.

  5. dbaeumer commented on Oct 3, 2017

    @dbaeumer
    Member

    Updated the documentation.

  6. added a commit that references this issue on Oct 3, 2017
    811a08b
  7. locked and limited conversation to collaborators on Nov 21, 2017
  8. added a commit that references this issue on Dec 28, 2017
    97b7ad0
  9. added a commit that references this issue on Jan 26, 2021
    9602ba9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions