Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Weird formatting with fold: true #56

Closed as not planned
Closed as not planned
@Inky-developer

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /