fix(graphical): stop rendering red vbars before the last item

This commit is contained in:
Kat Marchán 2021-09-21 12:51:20 -07:00
parent 858ac16935
commit e2e4027fda
1 changed files with 12 additions and 4 deletions

View File

@ -197,7 +197,8 @@ impl GraphicalReportHandler {
if let Some(cause) = diagnostic.source() { if let Some(cause) = diagnostic.source() {
let mut cause_iter = Chain::new(cause).peekable(); let mut cause_iter = Chain::new(cause).peekable();
while let Some(error) = cause_iter.next() { while let Some(error) = cause_iter.next() {
let char = if cause_iter.peek().is_some() { let is_last = cause_iter.peek().is_none();
let char = if !is_last {
self.theme.characters.lcross self.theme.characters.lcross
} else { } else {
self.theme.characters.lbot self.theme.characters.lbot
@ -208,9 +209,16 @@ impl GraphicalReportHandler {
) )
.style(severity_style) .style(severity_style)
.to_string(); .to_string();
let rest_indent = format!(" {} ", self.theme.characters.vbar) let rest_indent = format!(
.style(severity_style) " {} ",
.to_string(); if is_last {
' '
} else {
self.theme.characters.vbar
}
)
.style(severity_style)
.to_string();
let opts = textwrap::Options::new(width) let opts = textwrap::Options::new(width)
.initial_indent(&initial_indent) .initial_indent(&initial_indent)
.subsequent_indent(&rest_indent); .subsequent_indent(&rest_indent);