mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00
Extend BestFitting
with mode
(#6814)
This commit is contained in:
parent
71c25e4f9d
commit
34b2ae73b4
5 changed files with 181 additions and 15 deletions
|
@ -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) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue