Skip to content

Commit

Permalink
fix(graphical): stop rendering red vbars before the last item
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Sep 22, 2021
1 parent 858ac16 commit e2e4027
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/handlers/graphical.rs
Expand Up @@ -197,7 +197,8 @@ impl GraphicalReportHandler {
if let Some(cause) = diagnostic.source() {
let mut cause_iter = Chain::new(cause).peekable();
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
} else {
self.theme.characters.lbot
Expand All @@ -208,9 +209,16 @@ impl GraphicalReportHandler {
)
.style(severity_style)
.to_string();
let rest_indent = format!(" {} ", self.theme.characters.vbar)
.style(severity_style)
.to_string();
let rest_indent = format!(
" {} ",
if is_last {
' '
} else {
self.theme.characters.vbar
}
)
.style(severity_style)
.to_string();
let opts = textwrap::Options::new(width)
.initial_indent(&initial_indent)
.subsequent_indent(&rest_indent);
Expand Down

0 comments on commit e2e4027

Please sign in to comment.