From 85ccb98469596a595e747466b7fd789971203a6d Mon Sep 17 00:00:00 2001 From: David Alber Date: Wed, 13 Dec 2017 00:40:07 -0800 Subject: Adding test to verify code block idempotency in Configurations.md --- src/rustfmt_diff.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/rustfmt_diff.rs') diff --git a/src/rustfmt_diff.rs b/src/rustfmt_diff.rs index 69633568755..f37ab5c16ef 100644 --- a/src/rustfmt_diff.rs +++ b/src/rustfmt_diff.rs @@ -97,15 +97,28 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec Self { + match term::stdout() { + Some(ref t) if use_colored_tty(color) && t.supports_color() => PrintType::Fancy, + _ => PrintType::Basic, + } + } +} + pub fn print_diff(diff: Vec, get_section_title: F, color: Color) where F: Fn(u32) -> String, { - match term::stdout() { - Some(ref t) if use_colored_tty(color) && t.supports_color() => { - print_diff_fancy(diff, get_section_title, term::stdout().unwrap()) - } - _ => print_diff_basic(diff, get_section_title), + match PrintType::get(color) { + PrintType::Fancy => print_diff_fancy(diff, get_section_title, term::stdout().unwrap()), + PrintType::Basic => print_diff_basic(diff, get_section_title), } } -- cgit 1.4.1-3-g733a5