mirror of https://github.com/zkat/miette.git
fix(handler): do not call `supports_color::on` when color is forced
This reduces a sys call when color is forced. I'm not sure whether the logic after the change is correct or not, but the documentation seems to support it? https://docs.rs/miette/latest/miette/struct.MietteHandlerOpts.html#method.color > If true, colors will be used during graphical rendering, regardless of whether or not the terminal supports them. > > If false, colors will never be used. > > If unspecified, colors will be used only if the terminal supports them.
This commit is contained in:
parent
7ff4f874d6
commit
16f37e4778
|
|
@ -222,17 +222,17 @@ impl MietteHandlerOpts {
|
|||
};
|
||||
let styles = if self.color == Some(false) {
|
||||
ThemeStyles::none()
|
||||
} else if self.color == Some(true) {
|
||||
match self.rgb_colors {
|
||||
RgbColors::Always => ThemeStyles::rgb(),
|
||||
_ => ThemeStyles::ansi(),
|
||||
}
|
||||
} else if let Some(color) = supports_color::on(supports_color::Stream::Stderr) {
|
||||
match self.rgb_colors {
|
||||
RgbColors::Always => ThemeStyles::rgb(),
|
||||
RgbColors::Preferred if color.has_16m => ThemeStyles::rgb(),
|
||||
_ => ThemeStyles::ansi(),
|
||||
}
|
||||
} else if self.color == Some(true) {
|
||||
match self.rgb_colors {
|
||||
RgbColors::Always => ThemeStyles::rgb(),
|
||||
_ => ThemeStyles::ansi(),
|
||||
}
|
||||
} else {
|
||||
ThemeStyles::none()
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue