Skip to content

Incorrect folding when annotation span starts at 0 #116

Closed
@DaniPopes

Description

@DaniPopes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions