dart-lang / dart_style

An opinionated formatter/linter for Dart code
https://pub.dev/packages/dart_style
BSD 3-Clause "New" or "Revised" License
645 stars 117 forks source link

Eagerly bind AssignPiece if it can't block split and operands don't fit. #1477

Closed munificent closed 3 months ago

munificent commented 3 months ago

If neither of the two operands to an AssignPiece can be block formatted, and they contain newlines or the whole thing doesn't fit the page width, then the AssignPiece will definitely split at the operator.

This optimization helps a few rare cases (like deeply nested curried-style functions) from going pathological. I noticed it when migrating one of the regression tests over.

It doesn't have a noticeable affect on formatting the whole Flutter repo, but it doesn't hurt either.