diff options
| author | Kamal Marhubi <kamal@marhubi.com> | 2016-08-26 17:08:47 -0400 |
|---|---|---|
| committer | Kamal Marhubi <kamal@marhubi.com> | 2016-08-26 17:08:47 -0400 |
| commit | 05882314f5facdf4b7f7ffff3c4aecf747cdf176 (patch) | |
| tree | 6a8f6361287fd702022d0a0a61496b765b013c60 /src/rustfmt_diff.rs | |
| parent | 59e199b4393cb261865538944b527438eeb40a97 (diff) | |
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
Diffstat (limited to 'src/rustfmt_diff.rs')
| -rw-r--r-- | src/rustfmt_diff.rs | 4 |
1 files changed, 3 insertions, 1 deletions
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<F>(diff: Vec<Mismatch>, 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), } |
