fix(format): keep every formatter rule within its line #210

Merged
abiwab merged 1 commit from fix/formatter-line-breaks into main 2026-11-21 20:27:25 +01:00
Owner

Closes #197. Closes #202.

Four formatter rules could reach past the end of a line, so formatting (including format-on-save) could change a recipe or make it unparseable:

  • rules 2 (@id {) and 7 (->&name {}) used \s+, so they could join a brace from the next line;
  • rules 3 and 5 used \{([^}]*)\}, which ran on to the next }, however many lines down.

They now stick to spaces/tabs and [^{}\n]*, like rules 4 and 4b already did. Stopping at the next { also makes formatting linear on unclosed braces (#202).

Fuzz:

  • the 10 #197 entries leave the ratchet; their minimized inputs go into fuzz/regressions/ (each one fails on main with its original signature);
  • nested opening braces leaves KNOWN_SLOW;
  • three violations that the #197 signatures were hiding are added to the ratchet under their real issue: #200 (a line holding only a BOM, treated as blank by trimEnd but not by the parser) and #208 (a composite parent keeps its source case: @l<@N).

bun run fuzz --iterations 30000 --seed 2111373929: 0 new signatures. Tests for format, fuzz, LSP and CLI all pass.

Closes #197. Closes #202. Four formatter rules could reach past the end of a line, so formatting (including format-on-save) could change a recipe or make it unparseable: - rules 2 (`@id {`) and 7 (`->&name {}`) used `\s+`, so they could join a brace from the next line; - rules 3 and 5 used `\{([^}]*)\}`, which ran on to the next `}`, however many lines down. They now stick to spaces/tabs and `[^{}\n]*`, like rules 4 and 4b already did. Stopping at the next `{` also makes formatting linear on unclosed braces (#202). Fuzz: - the 10 #197 entries leave the ratchet; their minimized inputs go into `fuzz/regressions/` (each one fails on main with its original signature); - `nested opening braces` leaves `KNOWN_SLOW`; - three violations that the #197 signatures were hiding are added to the ratchet under their real issue: #200 (a line holding only a BOM, treated as blank by `trimEnd` but not by the parser) and #208 (a composite parent keeps its source case: `@l<@N`). `bun run fuzz --iterations 30000 --seed 2111373929`: 0 new signatures. Tests for format, fuzz, LSP and CLI all pass.
fix(format): keep every formatter rule within its line
All checks were successful
CI / Build & Test (pull_request) Successful in 4m50s
36327eae8b
abiwab merged commit 11d6e067ba into main 2026-11-21 20:27:25 +01:00
abiwab deleted branch fix/formatter-line-breaks 2026-11-21 20:27:25 +01:00
Sign in to join this conversation.
No description provided.