Do not overwrite files when there are no diffs in Overwrite mode
This commit is contained in:
parent
6a9d7dab0d
commit
a64037d0f0
@ -128,9 +128,12 @@ pub fn write_file<T>(text: &StringBuffer,
|
||||
}
|
||||
}
|
||||
WriteMode::Overwrite => {
|
||||
// Write text directly over original file.
|
||||
let file = File::create(filename)?;
|
||||
write_system_newlines(file, text, config)?;
|
||||
// Write text directly over original file if there is a diff.
|
||||
let (source, formatted) = source_and_formatted_text(text, filename, config)?;
|
||||
if source != formatted {
|
||||
let file = File::create(filename)?;
|
||||
write_system_newlines(file, text, config)?;
|
||||
}
|
||||
}
|
||||
WriteMode::Plain => {
|
||||
write_system_newlines(out, text, config)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user