mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
get rid of extra newlines
This commit is contained in:
parent
0e2c42d439
commit
2529fa0721
2 changed files with 40 additions and 19 deletions
|
@ -604,16 +604,17 @@ pub fn fmt_annotated_body_comment<'a>(
|
|||
}
|
||||
|
||||
for comment_or_newline in comment_iter {
|
||||
buf.newline();
|
||||
match comment_or_newline {
|
||||
roc_parse::ast::CommentOrNewline::Newline => (),
|
||||
roc_parse::ast::CommentOrNewline::DocComment(comment_str) => {
|
||||
buf.newline();
|
||||
buf.indent(indent);
|
||||
buf.push_str("# #");
|
||||
buf.spaces(1);
|
||||
buf.push_str(comment_str.trim());
|
||||
}
|
||||
roc_parse::ast::CommentOrNewline::LineComment(comment_str) => {
|
||||
buf.newline();
|
||||
buf.indent(indent);
|
||||
buf.push_str("#");
|
||||
buf.spaces(1);
|
||||
|
|
|
@ -6245,7 +6245,7 @@ mod test_fmt {
|
|||
x : i32
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -6256,7 +6256,7 @@ mod test_fmt {
|
|||
x : i32 # comment
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -6269,24 +6269,35 @@ mod test_fmt {
|
|||
# comment 2
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preserve_annotated_body_comments_with_newlines() {
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
x : i32
|
||||
fn preserve_annotated_body_comments_without_newlines() {
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r"
|
||||
x : i32
|
||||
|
||||
# comment
|
||||
# comment
|
||||
|
||||
# comment 2
|
||||
# comment 2
|
||||
|
||||
x = 1
|
||||
x
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
));
|
||||
),
|
||||
indoc!(
|
||||
r"
|
||||
x : i32
|
||||
# comment
|
||||
# comment 2
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -6297,20 +6308,29 @@ mod test_fmt {
|
|||
#
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preserve_annotated_body_with_newlines() {
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
fn preserve_annotated_body_without_newlines() {
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r"
|
||||
x : i32
|
||||
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
));
|
||||
"
|
||||
),
|
||||
indoc!(
|
||||
r"
|
||||
x : i32
|
||||
x = 1
|
||||
x
|
||||
"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// this is a parse error atm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue