-
Notifications
You must be signed in to change notification settings - Fork 821
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
Unspecified client behavior: textDocument/onTypeFormatting
#1430
Comments
See #1053 |
@rwols Thank you very much - that is quite helpful. (And I'm glad I'm not the only one who had that question. :-) ) I have one remaining question: is the location specified in the I think that a statement in the spec along the lines of @dbaeumer's advice might prevent future confusion; specifically (with minor copyediting):
@dbaeumer in #1053 I see your point about the specification not requiring a specific order of operations by the client other than ensuring that the server is up to date. On the other hand, not saying something explicit like…
or
or
or even (not recommended)
…leaves (IMO) too much room for variance in server behavior. This in turn, leaves client developers at the mercy of the "it works in VS Code, therefore it's correct" trap and in the unpleasant position of needing to support all kinds of server-specific special cases. So, if as @rwols describes in #1053 that the client can (and should) insert any text that it feels appropriate before syncing the changes to the server, I think that should be strengthened to "must" and then documented as such in the specification. And I think the specification would also do well to clarify whether the Thanks for reading. :-) |
The position doesn't denote any concrete insertion. Concrete insertion positions always come with document change events. The position denotes the position in the file |
Does this mean it's the server's responsibility to be flexible, and e.g. in the case of formatting after a newline, perform the same formatting whether the position in the request is just before or just after the newline? |
The idea is actually that the position indicates the cursor position (but since LSP allows sending arbitrary request, it can't be speced that way). So, the answer to your questions is yes. |
In the description for
textDocument/onTypeFormatting
, the specification says only:In the parameters, the comment for the
ch
parameter says only:What is not clear from this (and seems very important for a client developer to know) is whether the typed character should be entered into the document's contents (which to me also means that a
textDocument/didChange
notification is sent to the server) before thetextDocument/onTypeFormatting
request is sent.Or should none of that happen, and the client should send
textDocument/onTypeFormatting
before entering the character into the document's contents, and subsequently only do so if the server returns no edits?I'd be grateful if this could be explicitly specified (and I wouldn't mind knowing for my own edification, since the answer is immediately relevant to my interests :-) ).
The text was updated successfully, but these errors were encountered: