-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
fix(formatter): escape double quotes when printing formatter IR #3036
fix(formatter): escape double quotes when printing formatter IR #3036
Conversation
CodSpeed Performance ReportMerging #3036 will not alter performanceComparing Summary
|
e10f09e
to
5c4e3d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI should pass, but I'm not sure where to add a test for this.
Maybe you can refer to this test
biome/crates/biome_formatter/src/format_element/document.rs
Lines 718 to 752 in 312e46f
fn display_elements() { | |
let formatted = format!( | |
SimpleFormatContext::default(), | |
[format_with(|f| { | |
write!( | |
f, | |
[group(&format_args![ | |
text("("), | |
soft_block_indent(&format_args![ | |
text("Some longer content"), | |
space(), | |
text("That should ultimately break"), | |
]) | |
])] | |
) | |
})] | |
) | |
.unwrap(); | |
let document = formatted.into_document(); | |
assert_eq!( | |
&std::format!("{document}"), | |
r#"[ | |
group([ | |
"(", | |
indent([ | |
soft_line_break, | |
"Some longer content That should ultimately break" | |
]), | |
soft_line_break | |
]) | |
]"# | |
); | |
} |
5c4e3d0
to
e352ec5
Compare
Done. I've added a unit test for this. Thanks for the code pointer @ah-yu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @dyc3 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Summary
Double quotes in source code when printing formatter IR were previously not escaped, causing poor syntax highlighing on the playground. This PR escapes quotes with a simple string replacement.
fixes #1056
Test Plan
CI should pass,
but I'm not sure where to add a test for this.I've added a unit test for this.