From eb07d5bd66928457b4f3affe96aa6a0d39f642f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sat, 11 Sep 2021 00:57:53 -0700 Subject: [PATCH] fix(report): fix wrapping for header and add wrapping for footer --- src/handlers/graphical.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/handlers/graphical.rs b/src/handlers/graphical.rs index b8c9917..7de496e 100644 --- a/src/handlers/graphical.rs +++ b/src/handlers/graphical.rs @@ -126,11 +126,11 @@ impl GraphicalReportHandler { f, "{}{}", header, - self.theme - .characters - .hbar - .to_string() - .repeat(self.termwidth.saturating_sub(width)), + self.theme.characters.hbar.to_string().repeat( + self.termwidth + .saturating_sub(width) + .saturating_sub("Error: ".len()) + ), )?; Ok(()) } @@ -182,7 +182,12 @@ impl GraphicalReportHandler { if let Some(help) = diagnostic.help() { let help = help.style(self.theme.styles.help); 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(()) }