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 118 forks source link

Don't apply the page width optimization to already pinned pieces. #1449

Closed munificent closed 4 months ago

munificent commented 4 months ago

The last two commits clash and somehow the tests didn't fail on GitHub before merging. Maybe because I didn't merge the second commit with main on the PR branch before merging?

The string interpolation optimization pins pieces inside interpolation expressions. The page width optimization tries to bind pieces if it can tell they will always split. Those two optimizations collide if you have a very long expression inside a string interpolation.

The interpolation optimization pins it to not split, but then the later optimization tries to constrain it to always split, which fails.

This fixes that by skipping the page width optimization if the piece is already pinned.