Skip to content

Commit

Permalink
Only print a newline sep. when there is a header
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNeikos committed May 18, 2023
1 parent 66af796 commit 5b1d52a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/handlers/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ impl GraphicalReportHandler {
diagnostic: &(dyn Diagnostic),
) -> fmt::Result {
self.render_header(f, diagnostic)?;
writeln!(f)?;
self.render_causes(f, diagnostic)?;
let src = diagnostic.source_code();
self.render_snippets(f, diagnostic, src)?;
Expand Down Expand Up @@ -190,13 +189,15 @@ impl GraphicalReportHandler {
);
write!(header, "{}", link)?;
writeln!(f, "{}", header)?;
writeln!(f)?;
} else if let Some(code) = diagnostic.code() {
write!(header, "{}", code.style(severity_style),)?;
if self.links == LinkStyle::Text && diagnostic.url().is_some() {
let url = diagnostic.url().unwrap(); // safe
write!(header, " ({})", url.style(self.theme.styles.link))?;
}
writeln!(f, "{}", header)?;
writeln!(f)?;
}
Ok(())
}
Expand Down Expand Up @@ -301,7 +302,6 @@ impl GraphicalReportHandler {
Some(Severity::Advice) => write!(f, "Advice: ")?,
};
self.render_header(f, rel)?;
writeln!(f)?;
self.render_causes(f, rel)?;
let src = rel.source_code().or(parent_src);
self.render_snippets(f, rel, src)?;
Expand Down
8 changes: 4 additions & 4 deletions tests/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ fn single_line_highlight_span_full_line() {
let out = fmt_report(err.into());
println!("Error: {}", out);

let expected = r#"
× oops!
let expected = r#" × oops!
╭─[issue:1:1]
1 │ source
2 │ text
Expand Down Expand Up @@ -981,6 +980,7 @@ fn related() -> Result<(), MietteError> {
Error: oops::my::bad
× oops!
╭─[bad_file.rs:1:1]
1 │ source
Expand Down Expand Up @@ -1043,6 +1043,7 @@ fn related_source_code_propagation() -> Result<(), MietteError> {
Error: oops::my::bad
× oops!
╭─[bad_file.rs:1:1]
1 │ source
Expand Down Expand Up @@ -1201,8 +1202,7 @@ fn zero_length_eol_span() {
let out = fmt_report(err.into());
println!("Error: {}", out);

let expected = r#"
× oops!
let expected = r#" × oops!
╭─[issue:1:1]
1 │ this is the first line
2 │ this is the second line
Expand Down

0 comments on commit 5b1d52a

Please sign in to comment.