Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Fix interned IR printing of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Sep 1, 2022
1 parent 904ea9e commit 16f3aa2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions crates/rome_formatter/src/format_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,15 @@ impl Format<IrFormatContext> for FormatElement {
[
dynamic_text(&std::format!("<interned {index}>"), TextSize::default()),
space(),
&interned.0.as_ref()
]
)
)?;

match interned.0.as_ref() {
element @ FormatElement::Text(_) | element @ FormatElement::Space => {
write!(f, [text("\""), element, text("\"")])
}
element => element.fmt(f),
}
} else {
write!(
f,
Expand Down Expand Up @@ -1023,13 +1029,9 @@ impl<'a> Format<IrFormatContext> for &'a [FormatElement] {
matches!(element, FormatElement::Text(_) | FormatElement::Space);

if print_as_str {
write!(f, [text("\"")])?;
}

write!(f, [group(&element)])?;

if print_as_str {
write!(f, [text("\"")])?;
write!(f, [text("\""), &element, text("\"")])?;
} else {
write!(f, [group(&element)])?;
}

if index < len - 1 {
Expand Down

0 comments on commit 16f3aa2

Please sign in to comment.