Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/handlers/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 width](https://doc.rust-lang.org/std/fmt/#width) specifier.

```ignore
let diagnostic = // ...
println!("{diagnostic:300?}"); // Prints with 300 width instead of the configured value
```
*/
#[derive(Debug, Clone)]
pub struct GraphicalReportHandler {
Expand Down Expand Up @@ -1366,7 +1374,13 @@ impl ReportHandler for GraphicalReportHandler {
return fmt::Debug::fmt(diagnostic, f);
}

self.render_report(f, diagnostic)
if let Some(width) = f.width() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe .precision() is treated as maximum width for stringy / non-numeric types, would that make more sense?
https://doc.rust-lang.org/std/fmt/struct.Formatter.html#method.precision

let mut handler = self.clone();
handler.termwidth = width;
handler.render_report(f, diagnostic)
} else {
self.render_report(f, diagnostic)
}
}
}

Expand Down