Avoid parenthesizing unsplittable because of comments (#8431)

This commit is contained in:
Micha Reiser 2023-11-03 14:12:59 +09:00 committed by GitHub
parent a08c5b7fa7
commit dd2d8cb579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 781 additions and 35 deletions

View file

@ -20,7 +20,7 @@ impl FormatNodeRule<ExprAwait> for FormatExprAwait {
[
token("await"),
space(),
maybe_parenthesize_expression(value, item, Parenthesize::IfBreaks)
maybe_parenthesize_expression(value, item, Parenthesize::IfRequired)
]
)
}
@ -39,6 +39,7 @@ impl NeedsParentheses for ExprAwait {
context.comments().ranges(),
context.source(),
) {
// Prefer splitting the value if it is parenthesized.
OptionalParentheses::Never
} else {
self.value.needs_parentheses(self.into(), context)