mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
Removed denest and stopped manually newlining
This commit is contained in:
parent
728d3a069f
commit
d6a3f2cfe9
2 changed files with 13 additions and 27 deletions
|
@ -103,11 +103,9 @@ pub fn fmt_expr<'a>(
|
|||
};
|
||||
|
||||
for loc_pattern in loc_patterns.iter() {
|
||||
fmt_pattern(buf, denest_pattern(&loc_pattern.value), indent, true);
|
||||
fmt_pattern(buf, &loc_pattern.value, indent, true);
|
||||
|
||||
if arguments_are_multiline {
|
||||
newline(buf, indent);
|
||||
} else {
|
||||
if !arguments_are_multiline {
|
||||
buf.push(' ');
|
||||
}
|
||||
}
|
||||
|
@ -287,29 +285,6 @@ pub fn empty_line_before_expr<'a>(expr: &'a Expr<'a>) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn denest_pattern<'a>(pattern: &'a Pattern<'a>) -> &Pattern {
|
||||
match pattern {
|
||||
Pattern::SpaceBefore(unwrapped_pattern, _)
|
||||
| Pattern::SpaceAfter(unwrapped_pattern, _) => denest_pattern(unwrapped_pattern),
|
||||
Pattern::Nested(nested_pattern) => denest_pattern(nested_pattern),
|
||||
Pattern::Identifier(_)
|
||||
| Pattern::GlobalTag(_)
|
||||
| Pattern::PrivateTag(_)
|
||||
| Pattern::Apply(_, _)
|
||||
| Pattern::RecordDestructure(_)
|
||||
| Pattern::RecordField(_, _)
|
||||
| Pattern::IntLiteral(_)
|
||||
| Pattern::NonBase10Literal { .. }
|
||||
| Pattern::FloatLiteral(_)
|
||||
| Pattern::StrLiteral(_)
|
||||
| Pattern::BlockStrLiteral(_)
|
||||
| Pattern::EmptyRecordLiteral
|
||||
| Pattern::Underscore
|
||||
| Pattern::Malformed(_)
|
||||
| Pattern::QualifiedIdentifier(_) => pattern,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_multiline_pattern<'a>(pattern: &'a Pattern<'a>) -> bool {
|
||||
match pattern {
|
||||
Pattern::SpaceBefore(_, spaces) | Pattern::SpaceAfter(_, spaces) => {
|
||||
|
|
|
@ -519,6 +519,17 @@ mod test_format {
|
|||
identity 43
|
||||
"#
|
||||
));
|
||||
|
||||
expr_formats_same(indoc!(
|
||||
r#"
|
||||
identity = \a
|
||||
b
|
||||
# its b!!
|
||||
-> a
|
||||
|
||||
identity 43
|
||||
"#
|
||||
));
|
||||
}
|
||||
|
||||
// RECORD LITERALS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue