Fix: snippet escaping for resolved code action edits#4378
Merged
datho7561 merged 1 commit intoredhat-developer:mainfrom Mar 30, 2026
Merged
Conversation
datho7561
approved these changes
Mar 30, 2026
Contributor
datho7561
left a comment
There was a problem hiding this comment.
Seems good from my testing. Thanks, Amrita!
This file contains hidden or 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
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.
Summary
Fixes corruption of unrelated source text when applying resolved snippet-based code actions such as Add throws declaration.
Problem
The Java language server returns snippet edits that may contain:
\)$)${1|...|}These edits were passed directly into
SnippetString, causing VS Code to interpret literal characters as snippet syntax.This led to issues such as:
"Escaped\\Test\\Path"becoming"Escaped\Test\Path"page$content()becomingpage()Fix
Added
escapeSnippetLiterals()before creatingSnippetString.This safely escapes:
$characters that are not snippet placeholderswhile preserving valid placeholders like
${1|ExecutionException,Exception,Throwable|}.Verification
Tested using the reproducer project from #4314.
Verified that:
page$content()remains unchangedAdd throws declarationstill updates the method signature correctlyFixes #4314