Skip to content

Formatter: Wrap attributes based on maxLineLength only#1834

Open
andy-rootly wants to merge 4 commits into
marcoroth:mainfrom
andy-rootly:formatter-wrap-on-length
Open

Formatter: Wrap attributes based on maxLineLength only#1834
andy-rootly wants to merge 4 commits into
marcoroth:mainfrom
andy-rootly:formatter-wrap-on-length

Conversation

@andy-rootly

@andy-rootly andy-rootly commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1823 / #928. The count heuristic was surprising — <div a="1" b="2" c="3" d="4"> wrapped at 36 chars under the 80-char default, with no way for the user to opt out. After this PR, the same tag stays inline; long tags still wrap.

Test plan

  • CI passes (full formatter test suite — not run locally)
  • Existing snapshot fixtures still match, or are updated where the 4-attribute rule was load-bearing

Previously, the formatter wrapped tags one-attribute-per-line under two
conditions: when the opening tag would exceed `maxLineLength`, OR when
the tag had more than 3 attributes. The count rule was surprising in
practice — `<div a="1" b="2" c="3" d="4">` wrapped at 36 chars, well
under the 80-char default.

This removes the count rule. Wrapping is now driven purely by
`maxLineLength`, which matches user expectation and the docs.

Refs marcoroth#928, marcoroth#1823

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
andyw8 and others added 3 commits June 28, 2026 17:24
Five tests in CI still expected one-per-line wrapping based on the old
count heuristic. Under the new length-only behavior these inputs fit
within the 80-char default and stay inline; one test's input was widened
to genuinely exceed maxLineLength so it still demonstrates wrap behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The 71-char opening tag fits within maxLineLength so it stays inline,
but the whole `<div>...</div>Content` line is 85 chars, so the formatter
still moves the content onto separate lines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@andy-rootly andy-rootly marked this pull request as ready for review June 30, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants