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

Multi-line slices are not wrapping around when over by 1 #16

Closed
GodTamIt opened this issue Nov 25, 2019 · 0 comments
Closed

Multi-line slices are not wrapping around when over by 1 #16

GodTamIt opened this issue Nov 25, 2019 · 0 comments

Comments

@GodTamIt
Copy link
Contributor

GodTamIt commented Nov 25, 2019

Given this code:

let snippet = Snippet {
    title: Some("failed to parse file".to_owned()),
    footer: vec![],
    slices: vec![Slice {
        source: r#"This is an example
content of the slice
which will be annotated
with the list of annotations below."#
            .to_string(),
        line_start: 26,
        origin: Some("chris.beep".to_owned()),
        fold: false,
        annotations: vec![SourceAnnotation {
            label: "hello world".to_owned(),
            annotation_type: AnnotationType::Error,
            range: (13, 20),
        }],
    }],
};

This results in the following output:

error: failed to parse file
  --> chris.beep:26:13
   |
26 | This is an example
   |              ^^^^^^^ hello world
27 | content of the slice
28 | which will be annotated
29 | with the list of annotations below.

I would expect the underlining should wrap around to include the c of content on the next line. If we change the range from (13, 20) to (13, 21), that result includes the co of content being underlined.

GodTamIt added a commit to GodTamIt/annotate-snippets-rs that referenced this issue Jan 12, 2020
Fixes the error described in rust-lang#16. Previously, when a single character of
an annotation overflows to a new line, the DisplayList would incorrectly
consider that character on the same line. This change fixes this and
adds a new fixture test for this case.
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