mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00
parent
6bc1ba6d62
commit
039694aaed
5 changed files with 111 additions and 28 deletions
|
@ -459,8 +459,16 @@ impl Format<IrFormatContext<'_>> for &[FormatElement] {
|
|||
)?;
|
||||
}
|
||||
|
||||
StartLineSuffix => {
|
||||
write!(f, [text("line_suffix(")])?;
|
||||
StartLineSuffix { reserved_width } => {
|
||||
write!(
|
||||
f,
|
||||
[
|
||||
text("line_suffix("),
|
||||
dynamic_text(&std::format!("{reserved_width:?}"), None),
|
||||
text(","),
|
||||
space(),
|
||||
]
|
||||
)?;
|
||||
}
|
||||
|
||||
StartVerbatim(_) => {
|
||||
|
@ -672,7 +680,9 @@ impl FormatElements for [FormatElement] {
|
|||
match element {
|
||||
// Line suffix
|
||||
// Ignore if any of its content breaks
|
||||
FormatElement::Tag(Tag::StartLineSuffix | Tag::StartFitsExpanded(_)) => {
|
||||
FormatElement::Tag(
|
||||
Tag::StartLineSuffix { reserved_width: _ } | Tag::StartFitsExpanded(_),
|
||||
) => {
|
||||
ignore_depth += 1;
|
||||
}
|
||||
FormatElement::Tag(Tag::EndLineSuffix | Tag::EndFitsExpanded) => {
|
||||
|
|
|
@ -63,8 +63,11 @@ pub enum Tag {
|
|||
StartEntry,
|
||||
EndEntry,
|
||||
|
||||
/// Delay the printing of its content until the next line break
|
||||
StartLineSuffix,
|
||||
/// Delay the printing of its content until the next line break. Using reserved width will include
|
||||
/// the associated line suffix during measurement.
|
||||
StartLineSuffix {
|
||||
reserved_width: u32,
|
||||
},
|
||||
EndLineSuffix,
|
||||
|
||||
/// A token that tracks tokens/nodes that are printed as verbatim.
|
||||
|
@ -96,7 +99,7 @@ impl Tag {
|
|||
| Tag::StartIndentIfGroupBreaks(_)
|
||||
| Tag::StartFill
|
||||
| Tag::StartEntry
|
||||
| Tag::StartLineSuffix
|
||||
| Tag::StartLineSuffix { reserved_width: _ }
|
||||
| Tag::StartVerbatim(_)
|
||||
| Tag::StartLabelled(_)
|
||||
| Tag::StartFitsExpanded(_)
|
||||
|
@ -122,7 +125,7 @@ impl Tag {
|
|||
StartIndentIfGroupBreaks(_) | EndIndentIfGroupBreaks => TagKind::IndentIfGroupBreaks,
|
||||
StartFill | EndFill => TagKind::Fill,
|
||||
StartEntry | EndEntry => TagKind::Entry,
|
||||
StartLineSuffix | EndLineSuffix => TagKind::LineSuffix,
|
||||
StartLineSuffix { reserved_width: _ } | EndLineSuffix => TagKind::LineSuffix,
|
||||
StartVerbatim(_) | EndVerbatim => TagKind::Verbatim,
|
||||
StartLabelled(_) | EndLabelled => TagKind::Labelled,
|
||||
StartFitsExpanded { .. } | EndFitsExpanded => TagKind::FitsExpanded,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue