fix(report): fix wrapping for header and add wrapping for footer

This commit is contained in:
Kat Marchán 2021-09-11 00:57:53 -07:00
parent eaebde92cf
commit eb07d5bd66
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
1 changed files with 11 additions and 6 deletions

View File

@ -126,11 +126,11 @@ impl GraphicalReportHandler {
f, f,
"{}{}", "{}{}",
header, header,
self.theme self.theme.characters.hbar.to_string().repeat(
.characters self.termwidth
.hbar .saturating_sub(width)
.to_string() .saturating_sub("Error: ".len())
.repeat(self.termwidth.saturating_sub(width)), ),
)?; )?;
Ok(()) Ok(())
} }
@ -182,7 +182,12 @@ impl GraphicalReportHandler {
if let Some(help) = diagnostic.help() { if let Some(help) = diagnostic.help() {
let help = help.style(self.theme.styles.help); let help = help.style(self.theme.styles.help);
writeln!(f)?; writeln!(f)?;
writeln!(f, " {} {}", self.theme.characters.fyi, help)?; let width = self.termwidth.saturating_sub(4);
let initial_indent = format!(" {} ", self.theme.characters.fyi);
let opts = textwrap::Options::new(width)
.initial_indent(&initial_indent)
.subsequent_indent(" ");
writeln!(f, "{}", textwrap::fill(&help.to_string(), opts))?;
} }
Ok(()) Ok(())
} }