annotate-snippets-rs icon indicating copy to clipboard operation
annotate-snippets-rs copied to clipboard

Incorrect folding when annotation span starts at 0

Open DaniPopes opened this issue 1 year ago • 0 comments

I wrote a test to demonstrate this:

#[test]
fn unterminated_string_multiline() {
    let source = "\
a\"
// ...
";
    let input = Level::Error.title("").snippet(
        Snippet::source(source)
            .origin("file/path")
            .line_start(3)
            .fold(true)
            .annotation(Level::Error.span(0..10)), // 1..10 works
    );
    let expected = str![[r#"
error
--> file/path:1:1
 |
 |"#]]
    .indent(false);
    let renderer = Renderer::plain().anonymized_line_numbers(false);
    assert_eq(expected, renderer.render(input).to_string());
}

I believe this is incorrect as:

  • the line:column in the file path shows 1:1 regardless of the starting line
  • changing the span to start at 1 will correctly display the entire span rather than nothing

I believe this behavior is present since at least 0.10.0

DaniPopes avatar Apr 18 '24 01:04 DaniPopes