Closed michaelhthomas closed 2 days ago
I can't reproduce.
I'll try to publish a minimal reproduction.
Turns out this is a very specific case, and I'm a bit dumbfounded. The issue occurs when you have a comment expression containing two forward slashes (maybe these are being considered a comment as well?). In my case, this occurred because I included a URL in a comment. For example,
{/* Hello world */}
will not have any weird wrapping, but
{/* https://example.com */}
will be formatted as
- {/* https://example.com */}
+ {
+ /* https://example.com */
+ }
markup_fmt doesn't know those two slashes are in comments, and they're treated as line comments, such as:
{// xxx}
which causes wrapping.
Ah that makes sense. I feel like this is a bug, especially since afaik
{// comment}
isn't even valid syntax to begin with. Is it possible to have the parser keep track of whether it's already in a comment, and ignore the //?
However this can be valid:
{
// comment
}
It's a good idea for detecting this in parser.
It seems that there is a GitHub bug when I was commenting. It's re-opened now.
Currently, the following line:
is formatted as
in an Astro file. This is likely related more to the typescript plugin, just curious if there's any way to keep these on one line.