mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Remove mode
from BestFitting
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary This PR removes the `mode` field from `BestFitting` because it is no longer used (we now use `conditional_group` and `fits_expanded). <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan `cargo test` <!-- How was it tested? -->
This commit is contained in:
parent
715250a179
commit
9a8ba58b4c
4 changed files with 13 additions and 175 deletions
|
@ -57,10 +57,7 @@ pub enum FormatElement {
|
|||
|
||||
/// A list of different variants representing the same content. The printer picks the best fitting content.
|
||||
/// Line breaks inside of a best fitting don't propagate to parent groups.
|
||||
BestFitting {
|
||||
variants: BestFittingVariants,
|
||||
mode: BestFittingMode,
|
||||
},
|
||||
BestFitting { variants: BestFittingVariants },
|
||||
|
||||
/// A [Tag] that marks the start/end of some content to which some special formatting is applied.
|
||||
Tag(Tag),
|
||||
|
@ -87,10 +84,9 @@ impl std::fmt::Debug for FormatElement {
|
|||
.field(contains_newlines)
|
||||
.finish(),
|
||||
FormatElement::LineSuffixBoundary => write!(fmt, "LineSuffixBoundary"),
|
||||
FormatElement::BestFitting { variants, mode } => fmt
|
||||
FormatElement::BestFitting { variants } => fmt
|
||||
.debug_struct("BestFitting")
|
||||
.field("variants", variants)
|
||||
.field("mode", &mode)
|
||||
.finish(),
|
||||
FormatElement::Interned(interned) => {
|
||||
fmt.debug_list().entries(interned.deref()).finish()
|
||||
|
@ -301,29 +297,6 @@ impl FormatElements for FormatElement {
|
|||
}
|
||||
}
|
||||
|
||||
/// Mode used to determine if any variant (except the most expanded) fits for [`BestFittingVariants`].
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
||||
pub enum BestFittingMode {
|
||||
/// The variant fits if the content up to the first hard or a soft line break inside a [`Group`] with
|
||||
/// [`PrintMode::Expanded`] fits on the line. The default mode.
|
||||
///
|
||||
/// [`Group`]: tag::Group
|
||||
#[default]
|
||||
FirstLine,
|
||||
|
||||
/// A variant fits if all lines fit into the configured print width. A line ends if by any
|
||||
/// hard or a soft line break inside a [`Group`] with [`PrintMode::Expanded`].
|
||||
/// The content doesn't fit if there's any hard line break outside a [`Group`] with [`PrintMode::Expanded`]
|
||||
/// (a hard line break in content that should be considered in [`PrintMode::Flat`].
|
||||
///
|
||||
/// Use this mode with caution as it requires measuring all content of the variant which is more
|
||||
/// expensive than using [`BestFittingMode::FirstLine`].
|
||||
///
|
||||
/// [`Group`]: tag::Group
|
||||
AllLines,
|
||||
}
|
||||
|
||||
/// The different variants for this element.
|
||||
/// The first element is the one that takes up the most space horizontally (the most flat),
|
||||
/// The last element takes up the least space horizontally (but most horizontal space).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue