mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Fix fmt_spaces indenting in the context of 3 or more newlines
This commit is contained in:
parent
8ab7b121eb
commit
c6116ba3ca
2 changed files with 26 additions and 1 deletions
|
@ -46,7 +46,7 @@ where
|
||||||
match space {
|
match space {
|
||||||
Newline => {
|
Newline => {
|
||||||
if !encountered_comment && (consecutive_newlines < 2) {
|
if !encountered_comment && (consecutive_newlines < 2) {
|
||||||
if iter.peek() == Some(&&Newline) {
|
if iter.peek() == Some(&&Newline) && consecutive_newlines < 1 {
|
||||||
buf.push('\n');
|
buf.push('\n');
|
||||||
} else {
|
} else {
|
||||||
newline(buf, indent);
|
newline(buf, indent);
|
||||||
|
|
|
@ -2110,6 +2110,31 @@ mod test_fmt {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inner_def_with_triple_newline_before() {
|
||||||
|
expr_formats_to(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
\x ->
|
||||||
|
|
||||||
|
|
||||||
|
m1 = insert m n powerOf10
|
||||||
|
|
||||||
|
42
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
\x ->
|
||||||
|
|
||||||
|
m1 = insert m n powerOf10
|
||||||
|
|
||||||
|
42
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn when_guard() {
|
fn when_guard() {
|
||||||
expr_formats_same(indoc!(
|
expr_formats_same(indoc!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue