fix(reporter): fix extra newline after header

This commit is contained in:
Kat Marchán 2021-08-10 22:04:28 -04:00
parent 02dd1f84d4
commit 0d2e3312a4
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
2 changed files with 3 additions and 5 deletions

View File

@ -28,7 +28,6 @@ impl MietteReporter {
write!(f, " {}:", msg)?;
}
writeln!(f)?;
writeln!(f)?;
let context_data = snippet
.source
.read_span(&snippet.context)
@ -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:")?;
@ -135,7 +134,6 @@ impl DiagnosticReporter for MietteReporter {
}
if let Some(help) = diagnostic.help() {
writeln!(f)?;
writeln!(f)?;
write!(f, "﹦{}", help)?;
}

View File

@ -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(())
@ -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(())
}