You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't invalidate solutions from pinned pieces. (#1706)
If a string interpolation contains a splittable expression which in
turn contains an expression with a mandatory newline (like a multiline
string or `;`), then the solver gets confused.
The splittable expression is already pinned to state 0 to prevent there
from being newlines in the string interpolation. But now the newline
inside the subexpression tries to force the splittable expression to
split.
That leads the solver to invalidate the solution and then try to find
something better. Ultimately, it ends up unnecessarily splitting some
piece surrounding the interpolated string. (In the examples I've seen
in the wild, it's always a function's argument list.)
To avoid that, if a piece is already pinned, then we ignore invalidation
from it. This fixes the few rare cases I've seen in a large corpus and
doesn't impact anything else.
(Also, this fixes an edge case where the formatter in Dart 3.7 behaves
differently from the current formatter. The 3.7 formatter doesn't have
this bug. Something about the new shape-based solver seems to tickle
it. I'm not sure why.)
0 commit comments