Only newline with comma if last_ch == ] or }

This commit is contained in:
2025-10-02 09:59:37 +02:00
parent 5565f1340a
commit 4dce39e96b

View File

@@ -83,11 +83,16 @@ pub fn work(in_path:Option<&str>, out_path:Option<&str>) -> Result<(), String>
last_ch = ch;
},
',' => {
out_writer.write(format!("{}\n", ch).as_bytes()).unwrap();
out_writer.write(format!("{}", ch).as_bytes()).unwrap();
if last_ch == '}' || last_ch == ']' {
out_writer.write(b"\n").unwrap();
for _ in 0..tab_num {
out_writer.write(b" ").unwrap();
}
last_ch = ' ';
} else {
last_ch = ch;
}
},
_ => {
if ch != ' ' || last_ch != ' ' {