fix: param placeholders for types with right brace #2570
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).