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
72 if matches!(loc, CommentLocation::ItemInline) {72 if matches!(loc, CommentLocation::ItemInline) {
73 p!(pi: str(" "));73 p!(pi: str(" "));
74 }74 }
75 p!(pi: str("/* ") string(lines[0].trim().to_string()) str(" */"))75 p!(pi: str("/* ") string(lines[0].trim().to_string()) str(" */") nl)
76 } else if !lines.is_empty() {76 } else if !lines.is_empty() {
77 fn common_ws_prefix<'a>(a: &'a str, b: &str) -> &'a str {77 fn common_ws_prefix<'a>(a: &'a str, b: &str) -> &'a str {
78 let offset = a78 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)));