Enter-tainer / typstyle

Beautiful and reliable typst code formatter

Home Page:https://enter-tainer.github.io/typstyle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comments lost in set rule arguments

cpg314 opened this issue · comments

Thanks for this nice tool.

According to #16, nodes containing comments that are not currently supported should be skipped, so that they are not lost.
In the following example, the comment (a LineComment) actually is removed by typstyle:

#set text(
  size: 10pt,
  fallback: false,
  // lang: "de",
)
$ typstyle test.typ > test2.typ && diff test.typ test2.typ
5d4
<   // lang: "de",

The AST is:

$ typstyle -a test.typ
Markup: 63 [
    Hash: "#",
    SetRule: 61 [
        Set: "set",
        Space: " ",
        Ident: "text",
        Args: 53 [
            LeftParen: "(",
            Space: "\n  ",
            Named: 10 [
                Ident: "size",
                Colon: ":",
                Space: " ",
                Numeric: "10pt",
            ],
            Comma: ",",
            Space: "\n  ",
            Named: 15 [
                Ident: "fallback",
                Colon: ":",
                Space: " ",
                Bool: "false",
            ],
            Comma: ",",
            Space: "\n  ",
            LineComment: "// lang: \"de\",",
            Space: "\n",
            RightParen: ")",
        ],
    ],
    Space: "\n",
]

The problem is also present with 73558db

it's a bug. will fix later today