If there is an annotation of AnnotationKind::Primary that spans multiple lines, and also an annotation of AnnotationKind::Context that has the exact same span as the primary annotation, then the context label is colored using the primary color instead of the context color.
For example, in this test case, both annotations has span 35..58:
use annotate_snippets::{AnnotationKind, Level, Renderer, Snippet, renderer::DecorStyle};
use snapbox::{assert_data_eq, file};
#[test]
fn case() {
let source = r#"This is example of two annotations spanning
multiple lines with the exact same byte range."#;
// spanning
// multiple lines
let span = 35..58;
let input = &[Level::ERROR.primary_title("attention!").element(
Snippet::source(source)
.path("foo.txt")
.annotation(
AnnotationKind::Primary
.span(span.clone())
.label("primary label"),
)
.annotation(
AnnotationKind::Context
.span(span.clone())
.label("context label"),
),
)];
let expected_ascii = file!["ann_multiline_overlapping.ascii.term.svg": TermSvg];
let renderer = Renderer::styled();
assert_data_eq!(renderer.render(input), expected_ascii);
let expected_unicode = file!["ann_multiline_overlapping.unicode.term.svg": TermSvg];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
}
Notably, this visual error doesn't otherwise appear:
-
If the spans aren't equal:
(I notice that the renderer will collapse the line drawings if the spans are fully equal. Perhaps it is related to that?)
-
Or if the order in which the annotations are added is reversed (i.e. adding the context span first):
Also, possibly related to #427, with the added use of highlight_source(true) on the primary label, there is an additional visual glitch:
.annotation(
AnnotationKind::Primary
.span(span.clone())
.label("primary label"),
.highlight_source(true),
)
.annotation(
AnnotationKind::Context
.span(span.clone())
.label("context label"),
),

If there is an annotation of
AnnotationKind::Primarythat spans multiple lines, and also an annotation ofAnnotationKind::Contextthat has the exact same span as the primary annotation, then the context label is colored using the primary color instead of the context color.For example, in this test case, both annotations has span
35..58:Notably, this visual error doesn't otherwise appear:
If the spans aren't equal:
(I notice that the renderer will collapse the line drawings if the spans are fully equal. Perhaps it is related to that?)
Or if the order in which the annotations are added is reversed (i.e. adding the context span first):
Also, possibly related to #427, with the added use of
highlight_source(true)on the primary label, there is an additional visual glitch: