Skip to content

Commit

Permalink
Don't emit filename in diff mode, add filename to diff metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
juicejitsu committed Aug 10, 2016
1 parent 78b52ec commit a0de408
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/filemap.rs
Expand Up @@ -144,11 +144,11 @@ pub fn write_file<T>(text: &StringBuffer,
try!(write_system_newlines(stdout, text, config));
}
WriteMode::Diff => {
println!("Diff of {}:\n", filename);
if let Ok((ori, fmt)) = source_and_formatted_text(text, filename, config) {
let mismatch = make_diff(&ori, &fmt, 3);
let has_diff = !mismatch.is_empty();
print_diff(mismatch, |line_num| format!("\nDiff at line {}:", line_num));
print_diff(mismatch,
|line_num| format!("Diff in {} at line {}:", filename, line_num));
return Ok(has_diff);
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/system.rs
Expand Up @@ -350,3 +350,9 @@ fn rustfmt_diff_make_diff_tests() {
DiffLine::Context("d".into())],
}]);
}

#[test]
fn rustfmt_diff_no_diff_test() {
let diff = make_diff("a\nb\nc\nd", "a\nb\nc\nd", 3);
assert_eq!(diff, vec![]);
}

0 comments on commit a0de408

Please sign in to comment.