Skip to content

Commit

Permalink
fix(graphical): fix nested error wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLostLambda committed Mar 26, 2024
1 parent 1698551 commit a667134
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/handlers/graphical.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::{self, Write};

use owo_colors::{OwoColorize, Style, StyledList};
use unicode_width::UnicodeWidthChar;
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};

use crate::diagnostic_chain::{DiagnosticChain, ErrorKind};
use crate::handlers::theme::*;
Expand Down Expand Up @@ -354,6 +354,8 @@ impl GraphicalReportHandler {
inner_renderer.footer = None;
// Cause chains are already flattened, so don't double-print the nested error
inner_renderer.with_cause_chain = false;
// Since everything from here on is indented, shrink the virtual terminal
inner_renderer.termwidth -= rest_indent.width();
inner_renderer.render_report(&mut inner, diag)?;

writeln!(f, "{}", self.wrap(&inner, opts))?;
Expand Down
12 changes: 5 additions & 7 deletions tests/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,12 @@ fn wrapping_nested_errors() -> Result<(), MietteError> {
╰─▶ baby::error
× Wah wah: I may be small, but I'll
cause a
│ proper bout of trouble — just try
wrapping
│ this mess of a line, buddo!
│ cause a proper bout of trouble — just
│ try wrapping this mess of a line,
│ buddo!
help: it cannot be helped... would
youuuu
really want to get rid of an error
that's so cute?
youuuu really want to get rid of
an error that's so cute?
help: try doing it better next time? I mean,
you could have also done better this
Expand Down

0 comments on commit a667134

Please sign in to comment.