Open
Description
When rendering an annotation with fold: true
the first 4 lines get rendered if the source has more than 7 lines.
If the source has 7 or less lines, the first lines do not get rendered.
Example with source = "\n\n\n\n\n\n\nFoo"
:
error
|
...
8 | Foo
| ^^^ Error here
|
Example with source = "\n\n\n\n\n\n\n\nFoo"
:
error
|
1 |
2 |
3 |
4 |
...
8 |
9 | Foo
| ^^^ Error here
|
Minimal example:
use annotate_snippets::{
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};
fn print_snippet(source: &str, range: (usize, usize)) {
let s = Snippet {
title: Some(Annotation {
label: None,
id: None,
annotation_type: AnnotationType::Error,
}),
footer: Vec::new(),
slices: vec![Slice {
fold: true,
line_start: 1,
source,
origin: None,
annotations: vec![SourceAnnotation {
annotation_type: AnnotationType::Error,
label: "Error here",
range,
}],
}],
opt: FormatOptions::default(),
};
println!("{}", DisplayList::from(s));
}
fn main() {
print_snippet("\n\n\n\n\n\n\nFoo", (7, 10));
println!("\nVs\n");
print_snippet("\n\n\n\n\n\n\n\nFoo", (8, 11));
}
I am not sure if this is intended. In either case there should probably some way to disable this behavior.
Metadata
Metadata
Assignees
Labels
No labels