File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
crates/biome_formatter/src/format_element Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -250,7 +250,23 @@ impl Format<IrFormatContext> for &[FormatElement] {
250
250
FormatElement :: Space | FormatElement :: HardSpace => {
251
251
write ! ( f, [ text( " " ) ] ) ?;
252
252
}
253
- element if element. is_text ( ) => f. write_element ( element. clone ( ) ) ?,
253
+ element if element. is_text ( ) => {
254
+ // escape quotes
255
+ let new_element = match element {
256
+ // except for static text because source_position is unknown
257
+ FormatElement :: StaticText { .. } => element. clone ( ) ,
258
+ FormatElement :: DynamicText { text, source_position } => {
259
+ let text = text. to_string ( ) . replace ( "\" " , "\\ \" " ) ;
260
+ FormatElement :: DynamicText { text : text. into ( ) , source_position : * source_position }
261
+ } ,
262
+ FormatElement :: LocatedTokenText { slice, source_position } => {
263
+ let text = slice. to_string ( ) . replace ( "\" " , "\\ \" " ) ;
264
+ FormatElement :: DynamicText { text : text. into ( ) , source_position : * source_position }
265
+ } ,
266
+ _ => unreachable ! ( ) ,
267
+ } ;
268
+ f. write_element ( new_element) ?;
269
+ } ,
254
270
_ => unreachable ! ( ) ,
255
271
}
256
272
You can’t perform that action at this time.
0 commit comments