fix(handler): remove the two extra `is_terminal` sys call from `MietteHandlerOpts::build` (#325)

`GraphicalReportHandler::new()` calls `GraphicalTheme::default()`

7ff4f874d6/src/handlers/graphical.rs (L52)

which calls `std::io::stdout().is_terminal()` and `std::io::stderr().is_terminal()`

7ff4f874d6/src/handlers/theme.rs (L72)

but this default theme is overridden by `with_theme(theme)`.
This commit is contained in:
Boshen 2024-02-04 11:12:49 +08:00 committed by GitHub
parent cb2ae2e18b
commit f1dc89c076
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 3 deletions

View File

@ -247,10 +247,9 @@ impl MietteHandlerOpts {
ThemeStyles::none()
};
let theme = self.theme.unwrap_or(GraphicalTheme { characters, styles });
let mut handler = GraphicalReportHandler::new()
let mut handler = GraphicalReportHandler::new_themed(theme)
.with_width(width)
.with_links(linkify)
.with_theme(theme);
.with_links(linkify);
if let Some(with_cause_chain) = self.with_cause_chain {
if with_cause_chain {
handler = handler.with_cause_chain();