From f1dc89c07640445d224b61ef96c6b25fcdf62dee Mon Sep 17 00:00:00 2001 From: Boshen Date: Sun, 4 Feb 2024 11:12:49 +0800 Subject: [PATCH] fix(handler): remove the two extra `is_terminal` sys call from `MietteHandlerOpts::build` (#325) `GraphicalReportHandler::new()` calls `GraphicalTheme::default()` https://github.com/zkat/miette/blob/7ff4f874d693a665af4df40f4e94505013e3e262/src/handlers/graphical.rs#L52 which calls `std::io::stdout().is_terminal()` and `std::io::stderr().is_terminal()` https://github.com/zkat/miette/blob/7ff4f874d693a665af4df40f4e94505013e3e262/src/handlers/theme.rs#L72 but this default theme is overridden by `with_theme(theme)`. --- src/handler.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/handler.rs b/src/handler.rs index 38c9fc8..3c09373 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -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();