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

Possibly misleading statement about Message ordering #1693

Closed
Techatrix opened this issue Mar 21, 2023 · 6 comments
Closed

Possibly misleading statement about Message ordering #1693

Techatrix opened this issue Mar 21, 2023 · 6 comments

Comments

@Techatrix
Copy link

The Specification has the following to say about Message ordering:

For example, reordering the result of textDocument/completion and textDocument/signatureHelp is allowed, as each of these requests usually won’t affect the output of the other. On the other hand, the server most likely should not reorder textDocument/definition and textDocument/rename requests, since executing the latter may affect the result of the former.

I understand that a completion and signature request do not affect each other, but why doesn't the same apply to a definition and rename request? This seems to suggest that a rename request orders the server to compute and apply a rename. Usually this request is followed by a didChange that actually performs the edit.

@dbaeumer
Copy link
Member

Because the rename could change the result of the definition request. So if you first execute the rename although the definition request was executed on a different document version the result might be incorrect.

Hope that explains it.

@Techatrix
Copy link
Author

How is it possible that a rename request alters how the a request after it like definition or references should be handled?
Please correct me if I am wrong, but the rename request doesn't actually rename/modify a symbol or modify a document in any shape or form. Just like the Specification says, it only computes workspace change that can later be used to actually rename a symbol and thefore modify a document.
This is the description of the Rename request:

The rename request is sent from the client to the server to ask the server to compute a workspace change so that the client can perform a workspace-wide rename of a symbol.

As an example, if you use the "Rename Symbol" feature in VS-Code it will send a rename request followed by a didChange.
If you start a "Rename Symbol" and then ask for a preview, VS-Code will only send the rename request.

If there is no request that modifies a document like didChange is inbetween a references and rename request, they are both performed on the same document version. Whether or not the rename or references request comes first, shouldn't matter. Therefore, reordering or executing them in parallel should not pose a problem.

@dbaeumer
Copy link
Member

If the rename request sends it result first the client might apply the changes but the server still computes the definitions on an older state hence the client might use results that are off.

@Techatrix
Copy link
Author

If the rename request sends it result first the client might apply the changes but the server still computes the definitions on an older state hence the client might use results that are off.

Isn't this scenario achievable regardless of using message reordering. If a client send a sends a references request and then a didChange request and receives its responses in order (references first). The result has been computed before the didChange request and from the perspective of the client, the results are off because it has already modified that document in a previous request.

And also, does this only apply to the rename request? Can i reorder references, completion, semantic token, workspace symbol requests or similar if i don't change any state in between (e.g. with didChange) but not a rename request?

Just to make sure, whenever I talk about the rename request, i only mean sending a textDocument/rename without using its result. No document got modified.

@dbaeumer
Copy link
Member

Isn't this scenario achievable regardless of using message reordering. If a client send a sends a references request and then a didChange request and receives its responses in order (references first). The result has been computed before the didChange request and from the perspective of the client, the results are off because it has already modified that document in a previous request.

Yes, but the client knows about this and can act accordingly. For example by canceling the first request.

If the client doesn't use the result of the rename request then it would be fine to use the definition result.

@Techatrix
Copy link
Author

Does the rename or references request modify any state, document or may otherwise have any observable behavior and if so what exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants