fix(graphical): fix nested error wrapping

This commit is contained in:
Brooks J Rady 2024-03-26 15:23:06 -07:00
parent 1698551cdd
commit a66713470c
2 changed files with 8 additions and 8 deletions

View File

@ -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::*;
@ -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))?;

View File

@ -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