Skip to content

Commit

Permalink
fix(reporter): fix extra newline after header
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Aug 11, 2021
1 parent 02dd1f8 commit 0d2e331
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ impl MietteReporter {
write!(f, " {}:", msg)?;
}
writeln!(f)?;
writeln!(f)?;
let context_data = snippet
.source
.read_span(&snippet.context)
Expand Down Expand Up @@ -111,7 +110,7 @@ impl DiagnosticReporter for MietteReporter {
Some(Severity::Warning) => "Warning",
Some(Severity::Advice) => "Advice",
};
write!(f, "{}[{}]: {}", sev, diagnostic.code(), diagnostic)?;
writeln!(f, "{}[{}]: {}", sev, diagnostic.code(), diagnostic)?;

if let Some(cause) = diagnostic.source() {
write!(f, "\n\nCaused by:")?;
Expand All @@ -135,7 +134,6 @@ impl DiagnosticReporter for MietteReporter {
}

if let Some(help) = diagnostic.help() {
writeln!(f)?;
writeln!(f)?;
write!(f, "﹦{}", help)?;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn basic() -> Result<(), MietteError> {
};
let out = format!("{:?}", err);
assert_eq!(
"Error[oops::my::bad]: oops!\n﹦try doing it better next time?\n".to_string(),
"Error[oops::my::bad]: oops!\n\n﹦try doing it better next time?".to_string(),
out
);
Ok(())
Expand Down Expand Up @@ -68,6 +68,6 @@ fn fancy() -> Result<(), MietteError> {
};
let out = format!("{:?}", err);
// println!("{}", out);
assert_eq!("Error[oops::my::bad]: oops!\n\n[bad_file.rs] This is the part that broke:\n\n 1 | source\n 2 | text\n ⫶ | ^^^^ this bit here\n 3 | here\n﹦try doing it better next time?\n".to_string(), out);
assert_eq!("Error[oops::my::bad]: oops!\n\n[bad_file.rs] This is the part that broke:\n\n 1 | source\n 2 | text\n ⫶ | ^^^^ this bit here\n 3 | here\n﹦try doing it better next time?".to_string(), out);
Ok(())
}

0 comments on commit 0d2e331

Please sign in to comment.