Skip to content

refactor(fmt): use canonical layouts#15845

Draft
DaniPopes wants to merge 22 commits into
masterfrom
dani/fmt-canonical-layout
Draft

refactor(fmt): use canonical layouts#15845
DaniPopes wants to merge 22 commits into
masterfrom
dani/fmt-canonical-layout

Conversation

@DaniPopes

@DaniPopes DaniPopes commented Jul 21, 2026

Copy link
Copy Markdown
Member

This replaces formatter-side source-span and remaining-space estimates with retained canonical documents whose groups, fit probes, alternatives, conditional layout, and line suffixes are resolved by the renderer. It migrates declarations, assignments, function headers, call chains, comments, inline statements, and Yul layout to renderer-owned decisions, removes the duplicated size-estimation helpers, and measures layout in display columns rather than UTF-8 bytes.

Review-driven stabilization fixed the noncanonical header, declaration RHS, disabled-span, Yul comment, binary continuation, call-chain, struct, tuple-assignment, return, comment-alignment, and force/flatten interactions exposed during the migration. Assignment layout now composes a transparent RHS baseline with ordinary continuation and list indentation, avoiding source-dependent or first-nested-call state.

A final repository-wide fixture pass added adaptive call-chain continuations, preserved compact named calls on assignment continuations, and made single-line binary-return blocks depend on canonical rendered fit. Wrapping binary returns and their nested or if/else ancestors conservatively retain braces. Existing formatter golden outputs and repository Solidity fixtures are unchanged, while focused regressions cover the reviewed layout boundaries and second-pass convergence. Three independent final reviews found no remaining actionable issues.

AI assistance was used to research pretty-printing architectures, implement the retained-document migration, and independently review the resulting changes.

DaniPopes added 19 commits July 21, 2026 18:57
Replace source-span width estimates for wrapped line comments with named document groups. Track emitted breaks separately from overflowing unbreakable content and measure retained strings by display characters.
Replace assignment and initializer span-size arithmetic with structural formatter groups and continuation breaks. Keep lvalue and declaration heads stable while nested RHS documents choose their own layout.
Let retained document groups choose call-chain, assignment, and conditional layouts. Remove source-span estimators, remaining-space probes, callee byte counts, and block-depth width bookkeeping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant