Skip to content

Commit 386afdc

Browse files
committed
fix: fix detecting root when formatting script tag (fix #142)
1 parent 752e3a3 commit 386afdc

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
source: dprint_plugin/tests/integration.rs
3+
---
4+
<Component>
5+
<h1>Astro</h1>
6+
<script>
7+
console.log("1");
8+
console.log("2");
9+
</script>
10+
</Component>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
source: dprint_plugin/tests/integration.rs
3+
---
4+
<Component>
5+
<h1>Astro</h1>
6+
<script>
7+
console.log("1");
8+
console.log("2");
9+
</script>
10+
</Component>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Component>
2+
<h1>Astro</h1>
3+
<script>
4+
console.log("1");
5+
console.log("2");
6+
</script>
7+
</Component>

markup_fmt/src/printer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl<'s> DocGen<'s> for Element<'s> {
657657
let formatted = if is_json {
658658
ctx.format_json(text_node.raw, text_node.start, &state)
659659
} else {
660-
if is_script_indent && parent_tag_name.is_none() {
660+
if is_script_indent && is_root {
661661
state.indent_level += 1;
662662
}
663663
ctx.format_script(

0 commit comments

Comments
 (0)