git.delta.rocks / jrsonnet / refs/commits / 45b6682ad4a7

difftreelog

fix(fmt) multiline comment whitespace handling

Yaroslav Bolyukin2024-01-16parent: #e7b9349.patch.diff
in: master

2 files changed

modifiedcmds/jrsonnet-fmt/src/comments.rsdiffbeforeafterboth
--- a/cmds/jrsonnet-fmt/src/comments.rs
+++ b/cmds/jrsonnet-fmt/src/comments.rs
@@ -72,7 +72,7 @@
 					if matches!(loc, CommentLocation::ItemInline) {
 						p!(pi: str(" "));
 					}
-					p!(pi: str("/* ") string(lines[0].trim().to_string()) str(" */"))
+					p!(pi: str("/* ") string(lines[0].trim().to_string()) str(" */") nl)
 				} else if !lines.is_empty() {
 					fn common_ws_prefix<'a>(a: &'a str, b: &str) -> &'a str {
 						let offset = a
modifiedcmds/jrsonnet-fmt/src/main.rsdiffbeforeafterboth
372 return p!(new: str("{ }"));372 return p!(new: str("{ }"));
373 }373 }
374 let mut pi = p!(new: str("{") >i nl);374 let mut pi = p!(new: str("{") >i nl);
375 for mem in children.into_iter() {375 for (i, mem) in children.into_iter().enumerate() {
376 if mem.should_start_with_newline {376 if mem.should_start_with_newline && i != 0 {
377 p!(pi: nl);377 p!(pi: nl);
378 }378 }
379 p!(pi: items(format_comments(&mem.before_trivia, CommentLocation::AboveItem)));379 p!(pi: items(format_comments(&mem.before_trivia, CommentLocation::AboveItem)));