mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Always put a newline after a binop def body
This commit is contained in:
parent
9e19baef59
commit
8178f22ce4
1 changed files with 17 additions and 0 deletions
|
@ -324,6 +324,7 @@ pub fn fmt_body<'a, 'buf>(
|
||||||
) {
|
) {
|
||||||
pattern.format_with_options(buf, Parens::InApply, Newlines::No, indent);
|
pattern.format_with_options(buf, Parens::InApply, Newlines::No, indent);
|
||||||
buf.push_str(" =");
|
buf.push_str(" =");
|
||||||
|
|
||||||
if body.is_multiline() {
|
if body.is_multiline() {
|
||||||
match body {
|
match body {
|
||||||
Expr::SpaceBefore(sub_def, spaces) => {
|
Expr::SpaceBefore(sub_def, spaces) => {
|
||||||
|
@ -347,6 +348,22 @@ pub fn fmt_body<'a, 'buf>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Expr::BinOps(_, _) => {
|
||||||
|
// Binop chains always get a newline. Otherwise you can have things like:
|
||||||
|
//
|
||||||
|
// something = foo
|
||||||
|
// |> bar baz
|
||||||
|
//
|
||||||
|
// By always inserting a newline, this becomes:
|
||||||
|
//
|
||||||
|
// something =
|
||||||
|
// foo
|
||||||
|
// |> bar baz
|
||||||
|
//
|
||||||
|
// This makes it clear what the binop is applying to!
|
||||||
|
buf.newline();
|
||||||
|
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent + INDENT);
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
buf.spaces(1);
|
buf.spaces(1);
|
||||||
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);
|
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue