Removed denest and stopped manually newlining

This commit is contained in:
Chad Stearns 2019-12-16 13:21:25 -05:00
parent 728d3a069f
commit d6a3f2cfe9
2 changed files with 13 additions and 27 deletions

View file

@ -103,11 +103,9 @@ pub fn fmt_expr<'a>(
}; };
for loc_pattern in loc_patterns.iter() { 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 { if !arguments_are_multiline {
newline(buf, indent);
} else {
buf.push(' '); 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 { pub fn is_multiline_pattern<'a>(pattern: &'a Pattern<'a>) -> bool {
match pattern { match pattern {
Pattern::SpaceBefore(_, spaces) | Pattern::SpaceAfter(_, spaces) => { Pattern::SpaceBefore(_, spaces) | Pattern::SpaceAfter(_, spaces) => {

View file

@ -519,6 +519,17 @@ mod test_format {
identity 43 identity 43
"# "#
)); ));
expr_formats_same(indoc!(
r#"
identity = \a
b
# its b!!
-> a
identity 43
"#
));
} }
// RECORD LITERALS // RECORD LITERALS