You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
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.
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 ...
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.
Activity
kdvolder commentedon Aug 16, 2017
My opinion... if
didCloseis called only once thendidOpenshould also be called only once. This relates to: atom/atom-languageclient#88I 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.
amiramw commentedon Aug 19, 2017
There are two ways balancing the open/close count. You can call multiple times to
didOpenand multiple times todidCloseand make sure they are balanced or you can calldidOpenonce on the first open anddidCloseonce 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
didOpenafter the first one.I guess the second option make sense. I would prefer the protocol to state the expected behavior.
kdvolder commentedon Aug 22, 2017
That is not how I read the spec, but I know its how Atom does it at the moment.
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:
dbaeumer commentedon Oct 3, 2017
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.
dbaeumer commentedon Oct 3, 2017
Updated the documentation.
Fixes #285: Multiple didOpen calls
Fixes microsoft#285: Multiple didOpen calls
Fixes microsoft#285: Multiple didOpen calls