Skip to content

Commit 92d9ca7

Browse files
committed
Auto merge of #15876 - DropDemBits:lsp-ext-multiple-snippet-textedit, r=Veykril
minor: Allow multiple snippet edits in a `TextDocumentEdit` Explicitly[^1] allow a single `TextDocumentEdit` to have multiple `SnippetTextEdit`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](microsoft/vscode#145374 (comment)). The behavior described here lines up with [what VSCode does](https://github.com/microsoft/vscode/blob/bdc113ffe148a92d0e1a8ec34b12c44ea0b73f29/src/vscode-dts/vscode.d.ts#L3728-L3731), and presumably what the eventual LSP behavior will be. [^1]: This was technically the case before #15269, a single `TextDocumentEdit` always had multiple edits which were `InsertTextFormat.Snippet` as all of the edits were marked as being snippets, even if there weren't any tab stops or placeholders.
2 parents 8bfe0aa + 1e46868 commit 92d9ca7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: docs/dev/lsp-extensions.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ export interface TextDocumentEdit {
5757
}
5858
```
5959

60-
When applying such code action or text edit, the editor should insert snippet, with tab stops and placeholder.
61-
At the moment, rust-analyzer guarantees that only a single edit will have `InsertTextFormat.Snippet`.
60+
When applying such code action or text edit, the editor should insert snippet, with tab stops and placeholders.
61+
At the moment, rust-analyzer guarantees that only a single `TextDocumentEdit` will have edits which can be `InsertTextFormat.Snippet`.
62+
Any additional `TextDocumentEdit`s will only have edits which are `InsertTextFormat.PlainText`.
6263

6364
### Example
6465

0 commit comments

Comments
 (0)