--- 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 --- a/cmds/jrsonnet-fmt/src/main.rs +++ b/cmds/jrsonnet-fmt/src/main.rs @@ -372,8 +372,8 @@ return p!(new: str("{ }")); } let mut pi = p!(new: str("{") >i nl); - for mem in children.into_iter() { - if mem.should_start_with_newline { + for (i, mem) in children.into_iter().enumerate() { + if mem.should_start_with_newline && i != 0 { p!(pi: nl); } p!(pi: items(format_comments(&mem.before_trivia, CommentLocation::AboveItem)));