From 5f553cb91ad7c381d9a74d2c03ab13ed7da32c1f Mon Sep 17 00:00:00 2001 From: David Peter Date: Sun, 17 Oct 2021 17:56:30 +0200 Subject: [PATCH] Enable colors on Windows, closes #427 --- src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 434f35d..b0521fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -145,6 +145,10 @@ fn main() { fn build_hyperfine_options<'a>( matches: &ArgMatches<'a>, ) -> Result> { + // Enabled ANSI colors on Windows 10 + #[cfg(windows)] + colored::control::set_virtual_terminal(true).unwrap(); + let mut options = HyperfineOptions::default(); let param_to_u64 = |param| { matches @@ -216,11 +220,6 @@ fn build_hyperfine_options<'a>( } }; - // We default Windows to NoColor if full had been specified. - if cfg!(windows) && options.output_style == OutputStyleOption::Full { - options.output_style = OutputStyleOption::NoColor; - } - match options.output_style { OutputStyleOption::Basic | OutputStyleOption::NoColor => { colored::control::set_override(false)