From: Kamal Marhubi Date: Fri, 26 Aug 2016 21:08:47 +0000 (-0400) Subject: Check term supports colour before printing fancy diffs X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=05882314f5facdf4b7f7ffff3c4aecf747cdf176;p=rust.git Check term supports colour before printing fancy diffs For a terminal like DUMB, we were still attempting to print colourful diffs, which failed with a `NotSupported` error. Fixes #1140 --- diff --git a/src/rustfmt_diff.rs b/src/rustfmt_diff.rs index d5129bd1bca..23cb3f21bf2 100644 --- a/src/rustfmt_diff.rs +++ b/src/rustfmt_diff.rs @@ -89,7 +89,9 @@ pub fn print_diff(diff: Vec, get_section_title: F) where F: Fn(u32) -> String { match term::stdout() { - Some(_) if isatty() => print_diff_fancy(diff, get_section_title, term::stdout().unwrap()), + Some(ref t) if isatty() && t.supports_color() => { + print_diff_fancy(diff, get_section_title, term::stdout().unwrap()) + } _ => print_diff_basic(diff, get_section_title), }