Skip to content

Commit

Permalink
bump annotate-snippets to 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Jan 10, 2024
1 parent 75e3172 commit 0ed3382
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
23 changes: 7 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rustfmt-format-diff = []
generic-simd = ["bytecount/generic-simd"]

[dependencies]
annotate-snippets = { version = "0.9", features = ["color"] }
annotate-snippets = { version = "0.10" }
anyhow = "1.0"
bytecount = "0.6.4"
cargo_metadata = "0.15.4"
Expand Down
16 changes: 7 additions & 9 deletions src/format_report_formatter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::formatting::FormattingError;
use crate::{ErrorKind, FormatReport};
use annotate_snippets::display_list::{DisplayList, FormatOptions};
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
use std::fmt::{self, Display};

/// A builder for [`FormatReportFormatter`].
Expand Down Expand Up @@ -49,9 +48,10 @@ impl<'a> Display for FormatReportFormatter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let errors_by_file = &self.report.internal.borrow().0;

let opt = FormatOptions {
color: self.enable_colors,
..Default::default()
let renderer = if self.enable_colors {
Renderer::styled()
} else {
Renderer::plain()
};

for (file, errors) in errors_by_file {
Expand Down Expand Up @@ -91,9 +91,8 @@ impl<'a> Display for FormatReportFormatter<'a> {
title,
footer: footer.into_iter().collect(),
slices: vec![slice],
opt,
};
writeln!(f, "{}\n", DisplayList::from(snippet))?;
writeln!(f, "{}\n", renderer.render(snippet))?;
}
}

Expand All @@ -110,9 +109,8 @@ impl<'a> Display for FormatReportFormatter<'a> {
}),
footer: Vec::new(),
slices: Vec::new(),
opt,
};
writeln!(f, "{}", DisplayList::from(snippet))?;
writeln!(f, "{}", renderer.render(snippet))?;
}

Ok(())
Expand Down

0 comments on commit 0ed3382

Please sign in to comment.