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

Investigate viability of long-line wrapping #700

Open
Xophmeister opened this issue Apr 9, 2024 · 1 comment
Open

Investigate viability of long-line wrapping #700

Xophmeister opened this issue Apr 9, 2024 · 1 comment
Labels
epic: contributability Relates to how easy it is for external contributors to contribute to Topiary (engine and queries)

Comments

@Xophmeister
Copy link
Member

Xophmeister commented Apr 9, 2024

This has been mentioned a few times. For example:

  1. There doesn't seem to be a way to have something for max line width. Perhaps leveraging the softline captures to tell the formatter that it's ok to wrap long lines of code across multiple lines without requiring the developer to multiline first?

That's right; Topiary has no concept of line-length and using that as a constraint to force reflowing, like other formatters do. I'm not sure if this is "by design" or "by accident", but the general nature of Topiary means that it's not obvious how to wrap long lines in all cases.

Originally posted in #699 (review)

Per the comment, Topiary currently doesn't do anything with long-lines. It would be worth investigating whether anything suitably general can be done (e.g., forcing multiline mode at a certain column, etc.).

@ErinvanderVeen ErinvanderVeen added the epic: contributability Relates to how easy it is for external contributors to contribute to Topiary (engine and queries) label Apr 9, 2024
@aspiwack
Copy link
Member

aspiwack commented Apr 9, 2024

The difficulty is that as soon as you deal with long lines, then you have an optimisation problem to solve.

If you decide, for instance, that all the forms that cross the maximum column are considered multiline, you'll often make a lot of very short lines. So you need a more complex strategy. It's kind of tricky, this is where pretty printing libraries come in handy. I don't have a clear idea how such pretty printers and our current output strategy would meld.

But it is definitely a feature that some people want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic: contributability Relates to how easy it is for external contributors to contribute to Topiary (engine and queries)
Projects
None yet
Development

No branches or pull requests

3 participants