Repository navigation
fix: param placeholders for types with right brace - #2570
Closed
theofabilous wants to merge 1 commit into
Closed
theofabilous wants to merge 1 commit into
theofabilous wants to merge 1 commit into
Conversation
theofabilous
force-pushed
the
fix-func-snippet
branch
from
January 12, 2026 17:26
7c91e83 to
915bcf4
Compare
Member
|
Thank you for looking into this. Escaping Coincidentally I had also worked on a fix for the same issue. I already handled most of those edge cases I mentioned so I can save you the effort of updating this PR accordingly. See #2574. |
Author
|
Cool, glad to see that a fix was merged! |
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.
Completions for functions with snippet placeholders are broken when an argument's type is rendered with a right brace (
}). The right brace symbol is rendered unescaped, which causes snippet parsers to interpret it as the end of the placeholder, leaving an extra trailing}.Example:
This occurs (at least) in the following cases:
enum { ... })}(@"Evil}Name")std.ArrayList(struct {}), ...)Fixed by adding an
escape_r_bracesoption toFormatOptionsand escaping '}' symbols (as specified by LSP protocol - Snippet syntax) inType.rawStringify()when this option is set totrue. WhenrawStringifyParametercalls this function, it setsoptions.escape_r_bracestotrueif snippet placeholders are enabled.In
Type.rawStringify, I only specifically handleescape_r_bracesin cases where I've encountered this bug. There are a few lines in that function that render strings as is (without potentially escaping r-braces) which I didn't touch because I haven't encountered errors related to those code paths (and in most cases, wasn't sure if those code paths are reachable with snippet placeholders and/or can ever yield}symbols).I did this so that the changes map nicely onto the added test cases (removing any change causes at least one of the added tests to fail).