-
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
internal: Defer structured snippet rendering to allow escaping snippet bits #15269
Merged
bors
merged 6 commits into
rust-lang:master
from
DropDemBits:structured-snippets-deferred-rendering
Aug 1, 2023
Merged
internal: Defer structured snippet rendering to allow escaping snippet bits #15269
bors
merged 6 commits into
rust-lang:master
from
DropDemBits:structured-snippets-deferred-rendering
Aug 1, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rendering of snippet edits is deferred to places using source change
This ensures that any assist using structured snippets won't accidentally remove bits interpreted as snippet bits.
Also makes sure that stray placeholders get converted into tabstops
Structured snippets precisely track which text edits need to be marked as snippet text edits, but the cases where structured snippets aren't used but snippets are still present are for simple single text-edit changes, so it's perfectly fine to mark all one of them as being a snippet text edit
rustbot
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Jul 12, 2023
Marking as draft since I think I've found a way to test the text edit and snippet edit merging code. |
Had a missing ':' between the snippet index and placeholder text
Veykril
approved these changes
Aug 1, 2023
@bors r+ |
☀️ Test successful - checks-actions |
bors
added a commit
that referenced
this pull request
Nov 12, 2023
… 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since we know exactly where snippets are, we can transparently escape snippet bits to the exact text edits that need it, and not have to do it for anything other text edits.
Also will eventually fix #11006 once all assists are migrated. This comes as a side-effect of text edits that don't have snippets get marked as having no insert formatting at all.