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

Problem with Unix line feed annotation using empty ranges #135

Open
Volham22 opened this issue Jul 9, 2024 · 0 comments
Open

Problem with Unix line feed annotation using empty ranges #135

Volham22 opened this issue Jul 9, 2024 · 0 comments

Comments

@Volham22
Copy link

Volham22 commented Jul 9, 2024

Hello, thanks for your amazing work on this crate!

I recently encountered a problem while trying to annotate Unix line feeds (\n). When annotating line feeds with an empty Range, I got the following error:

error: bad
--> test.txt:1:1
 |
 |

This looks like a bug because doing the same thing on letters or digits works as expected:

error: bad
 --> test.txt:1:1
  |
1 | 111
  | ^
  |

Also, giving a non-empty Range solves the problem and outputs the annotation as expected:

error: bad
 --> test.txt:1:1
  |
1 | ...
  | ^
  |

Here is the code used to reproduce the problem (which occurs with the latest release). test.txt is a simple text file containing only Unix line feeds (\n):

use annotate_snippets::{Level, Renderer, Snippet};

pub fn reproduce_bug() {
    let renderer = Renderer::styled();
    let message = Level::Error.title("bad").snippet(
        Snippet::source(include_str!("../test.txt"))
            .origin("test.txt")
            .fold(true)
            .annotation(Level::Error.span(0..0)),
    );
    anstream::println!("{}", renderer.render(message));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant