mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Do not add parens around exprs if they are not needed in formatting
This commit is contained in:
parent
8a4975ee8a
commit
2ca9dad156
3 changed files with 33 additions and 4 deletions
|
@ -133,9 +133,13 @@ impl<'a> Formattable<'a> for Expr<'a> {
|
|||
}
|
||||
}
|
||||
ParensAround(sub_expr) => {
|
||||
buf.push('(');
|
||||
sub_expr.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);
|
||||
buf.push(')');
|
||||
if parens == Parens::NotNeeded {
|
||||
sub_expr.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);
|
||||
} else {
|
||||
buf.push('(');
|
||||
sub_expr.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);
|
||||
buf.push(')');
|
||||
}
|
||||
}
|
||||
Str(literal) => {
|
||||
use roc_parse::ast::StrLiteral::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue