-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
minor: Allow multiple snippet edits in a TextDocumentEdit
#15876
minor: Allow multiple snippet edits in a TextDocumentEdit
#15876
Conversation
Wasn't sure on which changelog prefix to use since it's only a documentation change (would minor work for this?). |
TextDocumentEdit
TextDocumentEdit
minor should be fine, lsp extension changes relevant for client implementations should be announced at #4604 fwiw |
@bors r+ |
☀️ Test successful - checks-actions |
@DropDemBits, do I understand correctly that currently rust-analyzer does not have a feature that creates a single TextDocumentEdit with multiple SnippetTextEdits? Once it has, can you, please, update the example section? It would help me to implement this in a LSP client. Thank you. |
@nemethf That is correct. It's something that I'm planning to do too, and I can also ping when I make the PR. |
@DropDemBits, have you made any progress on this? Thanks. |
@nemethf Sorry, just started working on rust-analyzer again recently after a bit of a break. I still have this tracked in my backlog, though with college running up again it's hard to find free time to work on stuff again. 😅 |
rust-lang/rust-analyzer#15876 https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_trait_from_impl.rs#L20 * eglot-x.el (eglot-x-enable-snippet-text-edit): Add link to an example. (eglot-x--unify-snippets, eglot-x--work-around-snippet-bug): New defuns. (eglot-x--apply-text-edits): Give a single, merged range to snippet-expansion-fn when there are multiple snippets in a text-edit.
Explicitly1 allow a single
TextDocumentEdit
to have multipleSnippetTextEdit
s. This allows things like renaming extracted variables and functions without having to go through a separate rename step. For an example of what this looks like, see the video in this comment.The behavior described here lines up with what VSCode does, and presumably what the eventual LSP behavior will be.
Footnotes
This was technically the case before internal: Defer structured snippet rendering to allow escaping snippet bits #15269, a single
TextDocumentEdit
always had multiple edits which wereInsertTextFormat.Snippet
as all of the edits were marked as being snippets, even if there weren't any tab stops or placeholders. ↩