Commit 370a8e3
fix(formatter): keep JSX expression child flat when fill expands its separator
Fixes #21916
When formatting a JSX child list, the printer's `Fill` correctly determined
that an expression entry (e.g. `{toCash(...).display_cents}`) fit in flat
mode even though the trailing separator needed to break. While printing
that flat entry, however, inner groups re-ran their own `fits` check using
`AllPredicate`, which walked past the entry boundary into subsequent fill
entries — frequently overshooting `printWidth` and causing the expression
group to needlessly expand into `{ \n expr \n }`.
This adds an `in_flat_fill_item` flag on the printer state that's set while
`print_fill_item` is printing a flat entry. Inner regular groups honor it
and skip re-measuring (since the fill already verified the entry fits),
while `BestFitting` still goes through its variant selection so JSX child
lists with both flat and expanded variants can still pick the right form.
Prettier conformance: no regressions (746/753 JS, 591/601 TS — unchanged).
Co-authored-by: Claude <[email protected]>1 parent 4380812 commit 370a8e3
2 files changed
Lines changed: 67 additions & 0 deletions
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
0 commit comments