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

Commit

Permalink
fix(rome_formatter): Printer fill fits (#3307)
Browse files Browse the repository at this point in the history
* fix(rome_formatter): Printer fill fits

* Undo unintended change
  • Loading branch information
MichaReiser committed Oct 1, 2022
1 parent 407dbbc commit 1fd9b7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion crates/rome_formatter/src/printer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ impl<'a> Printer<'a> {
// variant.

// Try to fit only the first variant on a single line

if !matches!(variant.first(), Some(&FormatElement::Tag(Tag::StartEntry))) {
return invalid_start_tag(TagKind::Entry, variant.first());
}
Expand Down Expand Up @@ -438,6 +437,8 @@ impl<'a> Printer<'a> {
let mut current_fits =
self.fits_fill_entry(SingleEntryPredicate::default(), queue, stack)?;

self.state.measured_group_fits = current_fits;

self.print_entry(
queue,
stack,
Expand All @@ -458,6 +459,8 @@ impl<'a> Printer<'a> {
false
};

self.state.measured_group_fits = all_fits;

let separator_mode = if all_fits {
PrintMode::Flat
} else {
Expand All @@ -480,6 +483,8 @@ impl<'a> Printer<'a> {
let next_fits =
self.fits_fill_entry(SingleEntryPredicate::default(), queue, stack)?;

self.state.measured_group_fits = next_fits;

self.print_entry(
queue,
stack,
Expand Down
6 changes: 3 additions & 3 deletions crates/rome_js_formatter/src/jsx/tag/closing_element.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::prelude::*;

use rome_formatter::{format_args, write};
use rome_formatter::write;
use rome_js_syntax::{JsxClosingElement, JsxClosingElementFields};

#[derive(Debug, Clone, Default)]
Expand All @@ -21,13 +21,13 @@ impl FormatNodeRule<JsxClosingElement> for FormatJsxClosingElement {

write![
formatter,
[group(&format_args![
[
l_angle_token.format(),
slash_token.format(),
name.format(),
line_suffix_boundary(),
r_angle_token.format(),
])]
]
]
}
}
4 changes: 2 additions & 2 deletions crates/rome_js_formatter/src/jsx/tag/opening_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Format<JsFormatContext> for JsxAnyOpeningElement {
line_suffix_boundary(),
space(),
attributes.format(),
line_suffix_boundary(),
(!attributes.is_empty()).then_some(line_suffix_boundary()),
attribute_spacing,
format_close
]
Expand All @@ -82,7 +82,7 @@ impl Format<JsFormatContext> for JsxAnyOpeningElement {
type_arguments.format(),
line_suffix_boundary(),
soft_line_indent_or_space(&attributes.format()),
line_suffix_boundary(),
(!attributes.is_empty()).then_some(line_suffix_boundary()),
]
)?;

Expand Down

0 comments on commit 1fd9b7b

Please sign in to comment.