mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
use Parens type in pattern formatting
This commit is contained in:
parent
6046d8ee8e
commit
e18d3bbfe4
5 changed files with 86 additions and 30 deletions
|
@ -1,3 +1,4 @@
|
|||
use crate::annotation::Parens;
|
||||
use crate::def::fmt_def;
|
||||
use crate::pattern::fmt_pattern;
|
||||
use crate::spaces::{
|
||||
|
@ -604,7 +605,13 @@ fn fmt_when<'a>(
|
|||
Some(last_pattern) => first_pattern.region.start_line != last_pattern.region.end_line,
|
||||
};
|
||||
|
||||
fmt_pattern(buf, &first_pattern.value, indent + INDENT, false, true);
|
||||
fmt_pattern(
|
||||
buf,
|
||||
&first_pattern.value,
|
||||
indent + INDENT,
|
||||
Parens::NotNeeded,
|
||||
true,
|
||||
);
|
||||
for when_pattern in rest {
|
||||
if is_multiline {
|
||||
buf.push_str("\n");
|
||||
|
@ -613,7 +620,13 @@ fn fmt_when<'a>(
|
|||
} else {
|
||||
buf.push_str(" | ");
|
||||
}
|
||||
fmt_pattern(buf, &when_pattern.value, indent + INDENT, false, true);
|
||||
fmt_pattern(
|
||||
buf,
|
||||
&when_pattern.value,
|
||||
indent + INDENT,
|
||||
Parens::NotNeeded,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(guard_expr) = &branch.guard {
|
||||
|
@ -782,7 +795,7 @@ pub fn fmt_closure<'a>(
|
|||
any_args_printed = true;
|
||||
}
|
||||
|
||||
fmt_pattern(buf, &loc_pattern.value, indent, false, false);
|
||||
fmt_pattern(buf, &loc_pattern.value, indent, Parens::NotNeeded, false);
|
||||
}
|
||||
|
||||
if !arguments_are_multiline {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue