Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config::default().with_color(false) not disable colors #54

Closed
mamcx opened this issue Dec 3, 2022 · 0 comments · Fixed by #61
Closed

Config::default().with_color(false) not disable colors #54

mamcx opened this issue Dec 3, 2022 · 0 comments · Fixed by #61
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mamcx
Copy link

mamcx commented Dec 3, 2022

Despite setting this to false, the colors are shown when added to labels:

pub fn build_report(
    named: String,
    err: &ErrorParser,
) -> Report<(String, Range<usize>)> {
    let mut colors = ColorGenerator::new();

    // Generate some colours for each of our elements
    let primary = colors.next();
    // let secondary = colors.next();
    let code = err.error_code();
    let config = Config::default().with_color(false);
    let diagnostic = Report::build(ReportKind::Error, named.clone(), 0)
        .with_code(code as usize)
        .with_config(config);

    match err {
        ErrorParser::ScalarParse { span, kind, msg } => diagnostic
            .with_message(msg)
            .with_label(
                Label::new((named, span.range()))
                    .with_message(msg)
                    .with_color(primary), <-- THIS CAUSE IT TO SHOW COLORS
            )
            .with_note(format!("Parsing value of type: {kind:?}"))
            .finish(),
        _ => {
            todo!()
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants