// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use config::Color;
use diff;
use std::collections::VecDeque;
use std::io;
use term;
-use utils::isatty;
+use utils::use_colored_tty;
#[derive(Debug, PartialEq)]
pub enum DiffLine {
results
}
-pub fn print_diff<F>(diff: Vec<Mismatch>, get_section_title: F)
+pub fn print_diff<F>(diff: Vec<Mismatch>, get_section_title: F, color: Color)
where
F: Fn(u32) -> String,
{
match term::stdout() {
- Some(ref t) if isatty() && t.supports_color() => {
+ 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),
]
);
}
+
+ #[test]
+ fn diff_trailing_newline() {
+ let src = "one\ntwo\nthree\nfour\nfive";
+ let dest = "one\ntwo\nthree\nfour\nfive\n";
+ let diff = make_diff(src, dest, 1);
+ assert_eq!(
+ diff,
+ vec![
+ Mismatch {
+ line_number: 5,
+ lines: vec![Context("five".into()), Expected("".into())],
+ },
+ ]
+ );
+ }
}