Skip to content

Commit ddc9fac

Browse files
authored
fix(fmt): panic on tagged HTML template with multi-level indent (#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 #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 #29963 Closes #33623 Closes #31820 Closes #30276 Closes #30980
1 parent 42f609c commit ddc9fac

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ dprint-core = "=0.67.4"
362362
dprint-plugin-json = "=0.21.3"
363363
dprint-plugin-jupyter = "=0.2.2"
364364
dprint-plugin-markdown = "=0.20.0"
365-
dprint-plugin-typescript = "=0.95.15"
365+
dprint-plugin-typescript = "=0.96.1"
366366
env_logger = "=0.11.6"
367367
fancy-regex = "=0.14.0"
368368
imara-diff = "=0.2.0"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tempDir": true,
3+
"tests": {
4+
"stdin": {
5+
"args": "fmt -",
6+
"input": "console.log(html`<a><svg viewBox=\"0 0 16 16\" width=\"20\" height=\"20\" fill=\"currentColor\">\n <path d=\"\" />\n</svg></a>`);\n",
7+
"output": "console.log(html`\n <a><svg viewBox=\"0 0 16 16\" width=\"20\" height=\"20\" fill=\"currentColor\">\n <path d=\"\" />\n </svg></a>\n`);\n"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)