typstfmt icon indicating copy to clipboard operation
typstfmt copied to clipboard

typstfmt Folds the Parameter List in Function Call even if `line_wrap = false` is Specified

Open FlandiaYingman opened this issue 11 months ago • 13 comments

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

Describe the bug typstfmt remove custom line breaks in function calls even with line_wrap setting to false.

To Reproduce Given a function call, for example

#figure(
  fletcher.diagram(
    node-outset: .5em,
    node-stroke: .075em,

    node((+1, 0), [variable], radius: 3em),
    node((+1.25, .75), [const], radius: 3em),

    edge((0, 0), (+1, 0), "=>"),
    edge((0.25, .75), (+1, 0), "->"),
    edge((0.25, .75), (+1.25, .75), "=>"),

    node((+0, 0), [pointer to \ variable], radius: 3em),
    node((-1, 0), [pointer to \ pointer to \ variable], radius: 3em),
    node((-.75, .75), [pointer to \ pointer to \ const], radius: 3em),
    node((+0.25, .75), [pointer to \ const], radius: 3em),

    edge((-1, 0), (+0, 0), "=>"),
    edge((-.75, .75), (+0, 0), "-X->"),
    edge((-.75, .75), (+0.25, .75), "=>"),
  )
)

with the default configuration plus line_wrap = false, typstfmt formats this piece of code into

#figure(
  fletcher.diagram(
    node-outset: .5em, node-stroke: .075em, node((+1, 0), [variable], radius: 3em), node((+1.25, .75), [const], radius: 3em), edge((0, 0), (+1, 0), "=>"), edge((0.25, .75), (+1, 0), "->"), edge((0.25, .75), (+1.25, .75), "=>"), node((+0, 0), [pointer to \ variable], radius: 3em), node((-1, 0), [pointer to \ pointer to \ variable], radius: 3em), node((-.75, .75), [pointer to \ pointer to \ const], radius: 3em), node((+0.25, .75), [pointer to \ const], radius: 3em), edge((-1, 0), (+0, 0), "=>"), edge((-.75, .75), (+0, 0), "-X->"), edge((-.75, .75), (+0.25, .75), "=>"),
  ),
)

which, in my perspective, worse than before.


I've tried various combination of options, but all yields unsatisfied result. I believe that we could prevent line breaking in function calls if line_wrap = false is specified, or add an extra option to handle this.

I noticed that there was a similar issue #134, however, that pull request seems to be closed?

FlandiaYingman avatar Mar 01 '24 11:03 FlandiaYingman