Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column option has no effect #75

Closed
mweinelt opened this issue May 25, 2024 · 8 comments
Closed

Column option has no effect #75

mweinelt opened this issue May 25, 2024 · 8 comments

Comments

@mweinelt
Copy link

Hi, thank you for creating and maintaining typstyle!

I noticed an issue with the --column option on 0.11.22 (from nixpkgs), where it would not enforce the default or any other configured column width. Wondering if my understanding of this option is wrong, or if the option is just broken at this point.

$ cat test.typ
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, 
no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et ju
sto duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

$ typstyle --column 80 test.typ
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, 
no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et ju
sto duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
typstyle 
Version:             0.11.22
Build Timestamp:     1980-01-01T00:00:00.000000000Z
Build Git Describe:  VERGEN_IDEMPOTENT_OUTPUT
Commit SHA:          VERGEN_IDEMPOTENT_OUTPUT
Commit Date:         None
Commit Branch:       None
Cargo Target Triple: x86_64-unknown-linux-gnu
@Enter-tainer
Copy link
Owner

one thing to notice is that column width is not a hard limit. and it mostly apply to scripting mode at this moment.

currently typsyle tend to keep content untouched. so the behavior is expected

@Enter-tainer Enter-tainer closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
@Dioprz
Copy link

Dioprz commented Jun 15, 2024

@Enter-tainer Hi! I'm migrating from typstfmt where max_line_length acted as a hard limit, so I'm noticing a difference in how typstyle handles this. Could you clarify what you meant by "it mostly apply to scripting mode at this moment"?

I'd also like to understand the purpose of a soft limit option. Is there a way to configure typstyle to enforce a hard limit like typstfmt did? I'm curious about the reasoning behind this design choice. Thanks!

@Enter-tainer
Copy link
Owner

can you show relevant code snippets so we can better understand it?

@Enter-tainer
Copy link
Owner

Enter-tainer commented Jun 16, 2024

Is there a way to configure typstyle to enforce a hard limit like typstfmt did?

To clarify this, typstyle only format code. this is one of the main design goals of typstyle:

Code only: We want to format only the code. Contents should be left untouched as much as possible.

I'd also like to understand the purpose of a soft limit option.
I'm curious about the reasoning behind this design choice.

reflowing content is very risky and error prone. and this only works for languages that use spaces to seprate words. for other languages, it is not even possible to do reflow.

Since we cannot do it well, i prefer not touch it and leave it as is.

why soft limit: hard limit is impossible to have on corner cases. like you have a variable name of 81 characters. no matter how you format the code, there is always a line exceed the 80 char limit. so typstyle cannot guarantee a hard limit. it can only try its best to meet the soft limit

@Enter-tainer
Copy link
Owner

Enter-tainer commented Jun 16, 2024

reflowing content is very risky and error prone.

see astrale-sharp/typstfmt#164 for example.

@Dioprz
Copy link

Dioprz commented Jun 17, 2024

Hm, yes, everything you say makes a lot of sense to me. I didn't think about the risks involved, but that example is a very strong argument (as well as the reasoning to create soft limits instead of hard limits).

Thanks for your time and the detailed explanation, I really appreciate it.

@Wulfheart
Copy link

But it would be nice if there was an option if "normal" text would get broken up after the column limit.

@Enter-tainer
Copy link
Owner

Enter-tainer commented Jul 7, 2024

@Wulfheart tracking in #104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants