Skip to content

fix: only keep the parens of a for of or for in statement beside a multi-line last value when the header doesn't fit on a line - #930

Merged
dsherret merged 1 commit into
mainfrom
fix-for-of-hug-only-when-needed
Nov 13, 2026
Merged

dsherret merged 1 commit into
mainfrom
fix-for-of-hug-only-when-needed

Conversation

@dsherret

Copy link
Copy Markdown
Member

Follow-up to #923.

Since #923 the parens of a for...of or for...in statement stay beside a multi-line right side. That also applied when the right side only became multi-line because of it, so a header that used to fit on its own line got its array or arguments broken up instead:

// 0.100.0
for (
  const s of ["", "A", "AA", "AAA", "AAAA", "AAAAA", "AA==", "AAA=", "A===", "=", "AAAA=="]
) {

// after #923
for (const s of [
  "",
  "A",
  ...
  "AAAA==",
]) {

Now the header is tried on its own lines first and stays that way when it fits on a single line there, which is what 0.100.0 did. The parens only stay beside the right side when it's multi-line either way:

for (const node of getPossibleSymbolReferenceNodes(
  indirectUser,
  isDefaultExport ? "default" : exportName,
)) {

Only one of the two layouts is printed at a time, so the condition remembers what it found out about each one at the position it's at.

Formatting the regressions repo with this, the hunks that got longer compared to 0.100.0 are gone, and what's left are the headers that now take two fewer lines.

…lti-line last value when the header doesn't fit on a line
@dsherret
dsherret merged commit aef337b into main Nov 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant