Clamp colors to valid values when parsing config

The oklch color space often creates weird values when parsed by csscolorparser.
clamping the output to values between 0 and 1 should fix inconsistent color handling
on borders.
This commit is contained in:
Andrew Davis
2025-06-11 00:34:33 -06:00
committed by Ivan Molodetskikh
parent aa47223c19
commit 07080a0431
+4 -1
View File
@@ -2677,7 +2677,10 @@ impl FromStr for Color {
type Err = miette::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let color = csscolorparser::parse(s).into_diagnostic()?.to_array();
let color = csscolorparser::parse(s)
.into_diagnostic()?
.clamp()
.to_array();
Ok(Self::from_array_unpremul(color))
}
}