Skip to content

__ gets lost from labels #53

@ndmitchell

Description

@ndmitchell

The starlark-rust library uses this code, specifically at https://github.com/facebookexperimental/starlark-rust/blob/13bec61a44dd2ec268403e1d6da4401ea76a3f12/starlark/src/errors/mod.rs#L205-L219. The relevant fragment is:

 let snippet = Snippet { title: Some(Annotation { label: Some(annotation_label), id: None, annotation_type: AnnotationType::Error, }), footer: Vec::new(), slices: slice.map(|s| vec![s]).unwrap_or_default(), opt: FormatOptions { color, ..Default::default() }, }; DisplayList::from(snippet)

However, if we have a label containing __, then that text gets lost from the label. The reason is that format_label in

for (idx, element) in label.split("__").enumerate() {
splits by __ to apply italics to alternate parts of the label. That behaviour was super surprising. I can't find it documented. There seems to be no way to turn it off, and no way to apply escaping to stop it happening. Can you suggest how I might get it so that errors don't get changed as they are rendered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-help-wantedCall for participation: Help is requested to fix this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions