zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.69k stars 74 forks source link

Config::default().with_color(false) not disable colors for `with_message` #120

Open Young-Flash opened 3 weeks ago

Young-Flash commented 3 weeks ago

Thanks for th great project

There is a issue which similar to https://github.com/zesterer/ariadne/issues/54

Config::default().with_color(false) don't work for 1

let mut report_builder =
    ariadne::Report::build(kind, source_file_path, self.location.start.offset as usize)
        .with_code(self.error_code)
        .with_message(&self.message)
        .with_label(
            ariadne::Label::new((
                source_file_path,
                self.location.start.offset as usize..self.location.end.offset as usize,
            ))
            .with_message((&self.message).fg(color)) //  <-------- 1
            .with_color(color),
        );

if !use_fancy {
    let config = ariadne::Config::default().with_color(false);
    report_builder = report_builder.with_config(config);
}

report_builder
    .finish()
    .print((source_file_path, ariadne::Source::from(source_file)))
    .unwrap();

I'd like to help fix this if you guys consider this is indeed a bug.