Skip to content

Commit

Permalink
fix(handler): remove the two extra is_terminal sys call from `Miett…
Browse files Browse the repository at this point in the history
…eHandlerOpts::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)`.
  • Loading branch information
Boshen committed Feb 4, 2024
1 parent cb2ae2e commit f1dc89c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f1dc89c

Please sign in to comment.