astrale-sharp / typstfmt

Apache License 2.0
253 stars 25 forks source link

[bug] `[\ ]` is wrongly formatted to a syntax error #88

Closed YDX-2147483647 closed 1 year ago

YDX-2147483647 commented 1 year ago

The following typst document compiles roughly to "→\n←". (\ impiles a new line)

→#[\ ]←

After formatted, the space is removed, so \ + ] combines into \], which is a syntax error.

$ typst compile main.typ
error: unclosed delimiter
  ┌─ main.typ:5:2
  │
5 │ →#[\]←
  │   ^

Yes I agree [\ ] is weird, but here's a real usage: https://github.com/GeorgeHoneywood/alta-typst/blob/85b3cdb1c364c833dec2ad3619cbe9d28085eb01/alta-typst.typ#L66 .

Workaround

Use an explicit linebreak instead.

astrale-sharp commented 1 year ago

I just tested it and it's fixed on master! I noticed it a while ago while testing against typst-brrrr ;)

can you confirm?

astrale-sharp commented 1 year ago

Have you been trying on typst-lsp instead of master?

YDX-2147483647 commented 1 year ago

I just checkout master (tag: 0.2.2) and indeed it's fixed, thank you!

Yes I have been using typst-lsp in VS Code. I chanced to find typst-lsp.experimentalFormatterMode when I was searching the settings.