mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-16 07:15:46 +00:00
Fix binary expression formatting with leading comments (#4964)
This commit is contained in:
parent
1accbeffd6
commit
646ab64850
3 changed files with 37 additions and 3 deletions
|
@ -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()])?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue