Extend BestFitting with mode (#6814)

This commit is contained in:
Micha Reiser 2023-08-23 17:23:45 +02:00 committed by GitHub
parent 71c25e4f9d
commit 34b2ae73b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 181 additions and 15 deletions

View file

@ -81,7 +81,7 @@ impl Document {
interned_expands
}
}
FormatElement::BestFitting { variants } => {
FormatElement::BestFitting { variants, mode: _ } => {
enclosing.push(Enclosing::BestFitting);
for variant in variants {
@ -326,7 +326,7 @@ impl Format<IrFormatContext<'_>> for &[FormatElement] {
write!(f, [text("line_suffix_boundary")])?;
}
FormatElement::BestFitting { variants } => {
FormatElement::BestFitting { variants, mode } => {
write!(f, [text("best_fitting([")])?;
f.write_elements([
FormatElement::Tag(StartIndent),
@ -342,7 +342,13 @@ impl Format<IrFormatContext<'_>> for &[FormatElement] {
FormatElement::Line(LineMode::Hard),
]);
write!(f, [text("])")])?;
write!(f, [text("]")])?;
if *mode != BestFittingMode::FirstLine {
write!(f, [dynamic_text(&std::format!(", mode: {mode:?}"), None),])?;
}
write!(f, [text(")")])?;
}
FormatElement::Interned(interned) => {