Fix binary expression formatting with leading comments (#4964)

This commit is contained in:
Micha Reiser 2023-06-09 11:02:50 +02:00 committed by GitHub
parent 1accbeffd6
commit 646ab64850
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 3 deletions

View file

@ -90,9 +90,8 @@ impl FormatNodeRule<ExprBinOp> for FormatExprBinOp {
]
)?;
// Format the operator on its own line if the operator has trailing comments and the right side has leading comments.
if !operator_comments.is_empty() && comments.has_leading_comments(right.as_ref().into())
{
// Format the operator on its own line if the right side has any leading comments.
if comments.has_leading_comments(right.as_ref().into()) {
write!(f, [hard_line_break()])?;
} else if needs_space {
write!(f, [space()])?;