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

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

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

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

DaniPopes opened this issue Apr 18, 2024 · 0 comments
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 Muscraft 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