Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-css-ratio-formatting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#9249](https://github.com/biomejs/biome/issues/9249): The CSS formatter no longer incorrectly breaks ratio values (like `1 / -1`) across lines when followed by comments.
22 changes: 11 additions & 11 deletions crates/biome_css_formatter/src/css/value/ratio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::prelude::*;
use biome_css_syntax::{CssRatio, CssRatioFields};
use biome_formatter::{format_args, write};
use biome_formatter::write;

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatCssRatio;
Expand All @@ -12,15 +12,15 @@ impl FormatNodeRule<CssRatio> for FormatCssRatio {
denominator,
} = node.as_fields();

write!(
f,
[group(&format_args![
numerator.format(),
space(),
slash_token.format(),
soft_line_break_or_space(),
denominator.format()
])]
)
let numbers = format_with(|f| {
let separator = soft_line_break_or_space();
let mut filler = f.fill();

filler.entry(&separator, &numerator.format());
filler.entry(&separator, &slash_token.format());
filler.entry(&separator, &denominator.format());
filler.finish()
});
write!(f, [group(&numbers)])
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.merch-grid {
grid-column: 1 / -1; /* The last column that will be used to position the shop link */
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: css/ratio/issue_9249.css
---

# Input

```css
.merch-grid {
grid-column: 1 / -1; /* The last column that will be used to position the shop link */
}

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
Trailing newline: true
-----

```css
.merch-grid {
grid-column: 1 / -1; /* The last column that will be used to position the shop link */
}

```

# Lines exceeding max width of 80 characters
```
2: grid-column: 1 / -1; /* The last column that will be used to position the shop link */
```