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

Incorrect folding when annotation span starts at 0 #116

Open
DaniPopes opened this issue Apr 18, 2024 · 0 comments
Open

Incorrect folding when annotation span starts at 0 #116

DaniPopes opened this issue Apr 18, 2024 · 0 comments
Labels
C-bug Category: bug

Comments

@DaniPopes
Copy link

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

@epage epage added the C-bug Category: bug label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants