Skip to content

Commit

Permalink
Fix a bug with in-place formatting
Browse files Browse the repository at this point in the history
The original file was getting overwritten but not truncated, which would
lead to weird output if the formatted file was shorter than the
original.
  • Loading branch information
Hubro committed Apr 18, 2023
1 parent 7a82caf commit c8162d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn main() {
if args.in_place {
let file_path = args.file_path.as_ref().unwrap();

let mut out = match std::fs::OpenOptions::new().write(true).open(file_path) {
let mut out = match std::fs::File::create(file_path) {
Ok(file) => file,
Err(err) => exit_with_error(format!("Failed to open file as writeable: {err}")),
};
Expand Down

0 comments on commit c8162d7

Please sign in to comment.