diff --git a/crates/rome_formatter/src/printer/mod.rs b/crates/rome_formatter/src/printer/mod.rs index e1b3246458b..88563cd1ad4 100644 --- a/crates/rome_formatter/src/printer/mod.rs +++ b/crates/rome_formatter/src/printer/mod.rs @@ -605,7 +605,7 @@ fn fits_on_line<'a>( pending_indent: printer.state.pending_indent, pending_space: printer.state.pending_space, line_width: printer.state.line_width, - has_line_suffix: printer.state.line_suffixes.len() > 0, + has_line_suffix: !printer.state.line_suffixes.is_empty(), }; let result = loop { @@ -747,12 +747,6 @@ fn fits_element_on_line<'a, 'rest>( } FormatElement::LineSuffix(_) => { - // The current behavior is to return `false` for all line suffixes if trying to print - // something in "flat" mode. - if args.mode.is_flat() { - return Fits::No; - } - state.has_line_suffix = true; } diff --git a/crates/rome_js_formatter/src/formatter.rs b/crates/rome_js_formatter/src/formatter.rs index ad02260f4af..8b3a89fba66 100644 --- a/crates/rome_js_formatter/src/formatter.rs +++ b/crates/rome_js_formatter/src/formatter.rs @@ -216,7 +216,10 @@ where ]), ] } else { - line_suffix(format_elements![space_token(), comment, space_token()]) + format_elements![ + line_suffix(format_elements![space_token(), comment]), + expand_parent() + ] }; elements.push(crate::comment(content)); diff --git a/crates/rome_js_formatter/src/js/expressions/assignment_expression.rs b/crates/rome_js_formatter/src/js/expressions/assignment_expression.rs index d000b469c52..68776cf3a66 100644 --- a/crates/rome_js_formatter/src/js/expressions/assignment_expression.rs +++ b/crates/rome_js_formatter/src/js/expressions/assignment_expression.rs @@ -21,6 +21,7 @@ impl FormatNodeFields for FormatNodeRule for FormatNodeRule