This commit is contained in:
Dion Dokter 2026-06-01 12:08:34 -07:00 committed by GitHub
commit 5889c93779
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 1 deletions

View File

@ -21,6 +21,14 @@ This printer can be customized by using [`new_themed()`](GraphicalReportHandler:
See [`set_hook()`](crate::set_hook) for more details on customizing your global
printer.
The width with which reports get printed depends on the configured width value, but can also get overridden per call
using the [Rust fmt precision](https://doc.rust-lang.org/std/fmt/#precision) specifier.
```ignore
let diagnostic = // ...
println!("{diagnostic:.300?}"); // Prints with 300 width instead of the configured value
```
*/
#[derive(Debug, Clone)]
pub struct GraphicalReportHandler {
@ -1366,7 +1374,13 @@ impl ReportHandler for GraphicalReportHandler {
return fmt::Debug::fmt(diagnostic, f);
}
self.render_report(f, diagnostic)
if let Some(width) = f.precision() {
let mut handler = self.clone();
handler.termwidth = width;
handler.render_report(f, diagnostic)
} else {
self.render_report(f, diagnostic)
}
}
}