Skip to content

Commit

Permalink
fix line comments in Astro expr
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Feb 19, 2024
1 parent caaf787 commit 939edd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions markup_fmt/src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'s> DocGen<'s> for AstroExpr<'s> {
}
});

Doc::text("{")
let doc = Doc::text("{")
.append(
Doc::line_or_nil()
.concat(
Expand All @@ -98,8 +98,12 @@ impl<'s> DocGen<'s> for AstroExpr<'s> {
.nest_with_ctx(ctx),
)
.append(Doc::line_or_nil())
.append(Doc::text("}"))
.group()
.append(Doc::text("}"));
if script.contains("//") {
doc
} else {
doc.group()
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion markup_fmt/tests/fmt/astro/other/jsx-comments.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
source: markup_fmt/tests/fmt.rs
---
{// Hello}
{
// Hello
}

{
// Hey
Expand Down

0 comments on commit 939edd5

Please sign in to comment.