forge
Explore
Log in

Don't you dare go Hollow

Clamp colors to valid values when parsing config

Browse files at this commit

07080a0431d86d64efed6fa557c2a02cb9041e93Andrew DavisParent: aa47223
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.
niri-config/src/lib.rsmodified+4 -1
@@ -2677,7 +2677,10 @@ impl FromStr for Color {
26772677 type Err = miette::Error;
26782678
26792679 fn from_str(s: &str) -> Result<Self, Self::Err> {
2680- let color = csscolorparser::parse(s).into_diagnostic()?.to_array();
2680+ let color = csscolorparser::parse(s)
2681+ .into_diagnostic()?
2682+ .clamp()
2683+ .to_array();
26812684 Ok(Self::from_array_unpremul(color))
26822685 }
26832686 }