catppuccin / whiskers

😾 Soothing port creation tool for the high-spirited!
MIT License
15 stars 2 forks source link

Whiskers breaks on some specific color overrides #32

Open dacid44 opened 2 months ago

dacid44 commented 2 months ago

When run with zed.tera, with a specific color override:

whiskers zed.tera -o json --color-overrides '{"all": {"text": "ff832b"}}'

whiskers crashes with the message:

thread 'main' panicked at /home/dacid44/.cargo/registry/src/index.crates.io-6f17d22bba15001f/css-colors-1.0.1/src/ratio.rs:38:9:
Invalid ratio for type f32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Changing the color to something slightly different (e.g. fe832b) fixes the error.

dacid44 commented 2 months ago

Actually, it looks like this is a bug in the css-colors crate. This code panics with the same error:

use css_colors::{rgb, Color};

fn main() {
    let weird_color = rgb(255, 131, 43); // #ff832b
    let weird_color_hsl = weird_color.to_hsla();
    println!("Hello, world!");
}

Unfortunately, I don't think it's likely that that crate is going to be patched anytime soon. The last commit is from 5 years ago, and seems completely dead. Their issue tracker is all old and unanswered stuff too.

backwardspy commented 2 months ago

that is interesting, thanks for raising this! i suspect you're right. i have a few ideas already for replacing css-colors.

i will have a look into this and see what to do about working around it or fixing it.