astrale-sharp / typstfmt

Apache License 2.0
253 stars 25 forks source link

Comments and trailing content blocks don't go well together #124

Open miliog opened 1 year ago

miliog commented 1 year ago

[x] I have tested with the master version of typstfmt and not just typst-lsp

When using trailing multi-line content blocks with comments right after the [, the output becomes very confusing and not how I think it should look like.

 #let test(..args) = (
   // do something
 )

 #test(
   a: "test test test test test",
   b: "test test test test test",
 )[ /* test */
   test test test test test test test test test test test test test test test test test test test test test test test test
 ][ /* test */
   test test test test test test test test test test test test test test test test test test test test test test test test
 ][ /* test */
   test test test test test test test test test test test test test test test test test test test test test test test test
 ]

turns into

#test(
  a: "test test test test test",
  b: "test test test test test",
)[ /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test ][ /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test ][ /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test ]

However, I'd like it to look like this:

#test(
  a: "test test test test test",
  b: "test test test test test",
)[ /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test
][ /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test
][ /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test
]

Without the comments or if I place the comments in the next line, it works just fine:

#test(
  a: "test test test test test",
  b: "test test test test test",
)[
  /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test
][
  /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test
][
  /* test */
  test test test test test test test test test test test test test test test test
  test test test test test test test test
]
astrale-sharp commented 1 year ago

Interesting, thanks for the report!