From 0d2e3312a4a262e99a131bc893097d295e59e8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Tue, 10 Aug 2021 22:04:28 -0400 Subject: [PATCH] fix(reporter): fix extra newline after header --- src/reporter.rs | 4 +--- tests/reporter.rs | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/reporter.rs b/src/reporter.rs index 42177b4..9ab70d3 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -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)?; } diff --git a/tests/reporter.rs b/tests/reporter.rs index b220530..7a52aee 100644 --- a/tests/reporter.rs +++ b/tests/reporter.rs @@ -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(()) }