@@ -264,6 +264,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
264264
265265 // If true, all input files were already formatted (used for check mode)
266266 let mut all_formatted = true ;
267+ let mut modified_file_count = 0 ;
267268 for output in sorted_outputs {
268269 match output {
269270 Ok ( output) => {
@@ -282,14 +283,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
282283 println ! ( "#--file:{}" , output. file_path. display( ) ) ;
283284 }
284285 print ! ( "{}" , output. formatted_content) ;
285- } else {
286- fs:: write ( & output. file_path , output. formatted_content ) . map_err ( |e | {
286+ } else if !output . is_formatted {
287+ fs:: write ( & output. file_path , output. formatted_content ) . map_err ( |error | {
287288 format ! (
288289 "Failed to write to file {}: {}" ,
289290 output. file_path. display( ) ,
290- e
291+ error
291292 )
292293 } ) ?;
294+ modified_file_count += 1 ;
293295 }
294296 }
295297 Err ( error_msg) => {
@@ -310,9 +312,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
310312 } else if !args. stdout {
311313 terminal_clear_line ( ) ;
312314 if total_files == 1 {
313- eprintln ! ( "\r Formatted {}" , input_gdscript_files[ 0 ] . display( ) ) ;
315+ if modified_file_count > 0 {
316+ eprintln ! ( "\r Formatted {}" , input_gdscript_files[ 0 ] . display( ) ) ;
317+ } else {
318+ eprintln ! ( "\r Already formatted: {}" , input_gdscript_files[ 0 ] . display( ) ) ;
319+ }
314320 } else {
315- eprintln ! ( "\r Formatted {} files" , total_files) ;
321+ let already_formatted_count = total_files - modified_file_count;
322+ if modified_file_count > 0 && already_formatted_count > 0 {
323+ eprintln ! (
324+ "\r Formatted {} files, {} already formatted" ,
325+ modified_file_count, already_formatted_count
326+ ) ;
327+ } else if modified_file_count > 0 {
328+ eprintln ! ( "\r Formatted {} files" , modified_file_count) ;
329+ } else {
330+ eprintln ! ( "\r All {} files already formatted" , total_files) ;
331+ }
316332 }
317333 }
318334
0 commit comments