Skip to content

fix(fmt): panic on tagged HTML template with multi-level indent - #34263

Merged
bartlomieju merged 2 commits into
denoland:mainfrom
bartlomieju:fix/fmt-tagged-template-multi-indent
May 20, 2026
Merged

bartlomieju merged 2 commits into
denoland:mainfrom
bartlomieju:fix/fmt-tagged-template-multi-indent

Conversation

@bartlomieju

@bartlomieju bartlomieju commented May 20, 2026 •

Copy link
Copy Markdown
Member

deno fmt panics with finish_indent was called without a corresponding start_indent when a tagged HTML/SVG template embeds content whose
formatted output transitions by more than one indent level between
adjacent lines. The minimal repro from #29963 is

console.log(html`<a><svg viewBox="0 0 16 16" width="20" height="20" fill="currentColor">
  <path d="" />
</svg></a>`);

markup_fmt produces lines at indent levels 0 → 2 → 1, and
dprint-plugin-typescript's embedded-template path emitted only a
single StartIndent/FinishIndent per transition while its
end-of-template cleanup emitted one signal per remaining level, leaving
the dprint IR unbalanced.

The fix is in dprint-plugin-typescript
(dprint/dprint-plugin-typescript#783) and is consumed here by bumping
the pin to =0.96.1. A spec regression test in
tests/specs/fmt/embedded_html_multi_indent covers the case using the
exact input from the issue and asserts the expected formatted output.

Marking as draft until dprint-plugin-typescript 0.96.1 is published;
once it lands on crates.io this is ready to merge as-is.

Closes #29963
Closes #33623
Closes #31820
Closes #30276
Closes #30980

Pin dprint-plugin-typescript 0.96.1, which contains
dprint/dprint-plugin-typescript#783. That release fixes a panic in
`deno fmt` when a tagged HTML/SVG template embeds content whose
formatted output transitions by more than one indent level between
adjacent lines (e.g. `<a><svg ...><path/></svg></a>`). Adds a spec
regression test using the minimal repro from issue denoland#29963.

Closes denoland#29963.
@bartlomieju bartlomieju mentioned this pull request May 20, 2026
@bartlomieju
bartlomieju marked this pull request as ready for review May 20, 2026 13:52
@bartlomieju
bartlomieju merged commit ddc9fac into denoland:main May 20, 2026
268 of 306 checks passed
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…land#34263)

`deno fmt` panics with `finish_indent was called without a corresponding
start_indent` when a tagged HTML/SVG template embeds content whose
formatted output transitions by more than one indent level between
adjacent lines. The minimal repro from denoland#29963 is

```js
console.log(html`<a><svg viewBox="0 0 16 16" width="20" height="20" fill="currentColor">
  <path d="" />
</svg></a>`);
```

`markup_fmt` produces lines at indent levels 0 → 2 → 1, and
`dprint-plugin-typescript`'s embedded-template path emitted only a
single `StartIndent`/`FinishIndent` per transition while its
end-of-template cleanup emitted one signal per remaining level, leaving
the dprint IR unbalanced.

The fix is in `dprint-plugin-typescript`
(dprint/dprint-plugin-typescript#783) and is consumed here by bumping
the pin to `=0.96.1`. A spec regression test in
`tests/specs/fmt/embedded_html_multi_indent` covers the case using the
exact input from the issue and asserts the expected formatted output.

Closes denoland#29963
Closes denoland#33623
Closes denoland#31820
Closes denoland#30276
Closes denoland#30980
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant