Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Displaying LF in CRLF shows 1:1 in line:col #117

Closed
DaniPopes opened this issue Apr 18, 2024 · 1 comment
Closed

Displaying LF in CRLF shows 1:1 in line:col #117

DaniPopes opened this issue Apr 18, 2024 · 1 comment
Labels
C-bug Category: bug

Comments

@DaniPopes
Copy link

DaniPopes commented Apr 18, 2024

I wrote a test to demonstrate this:

#[test]
fn lf_in_crlf() {
    let source = "a\r\nb";
    let input = Level::Error.title("").snippet(
        Snippet::source(source)
            .origin("file/path")
            .line_start(3)
            .annotation(Level::Error.span(2..3)), // \n
    );
    let expected = str![[r#"
error
 --> file/path:1:1
  |
3 |   a
4 | | b
  | |_^
  |"#]]
    .indent(false);
    let renderer = Renderer::plain().anonymized_line_numbers(false);
    assert_eq(expected, renderer.render(input).to_string());
}

This only happens when a span points to exactly the \n byte that's preceded by \r

I believe this behavior is present since at least 0.10.0

@Muscraft
Copy link
Member

This was fixed in #131

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants