-
Notifications
You must be signed in to change notification settings - Fork 3
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
Automatic line breaking #61
Comments
There is no plan, much less a timeline 🙂
Yea, this is a fair point. Personally I naturally line break when lines become too long based on editor guidelines so I never really end up with long lines to begin with. I have thought about having a line length limit based on something like If this is implemented I would also only break lines where there already are natural breakpoints, for example, I don't think automatically splitting strings (or comments) should be done. In practice I think line overflows is mostly happening in long function calls or function signatures, so that shouldn't be too difficult to implement as a starting point.
Okay, I don't know if such balancing is better in general, perhaps you have something like functioncall(foo1, foo2, foo3, bar1, bar2, bar3, baz1, baz2) and if such a line is balanced it would become e.g. functioncall(
foo1, foo2, foo3, bar1,
bar2, bar3, baz1, baz2
) If the formatter does this you realize the line was too long, but you rather want to keep the functioncall(
foo1, foo2, foo3, bar1, bar2, bar3,
baz1, baz2
) (would JuliaFormatter keep this as is or is balancing always enforced also on lines that don't overflow?). functioncall(
foo1, foo2, foo3, bar1, bar2, bar3, baz1,
baz2
) and then manually format into functioncall(
foo1, foo2, foo3, bar1, bar2, bar3,
baz1, baz2
) Perhaps this isn't such a common case though, but I kind of like the simplicity of not trying to guess or do balancing. |
It will keep manually broken lines, only balancing while automatically breaking a line. |
As an alternative first step, perhaps the |
Our current JuliaFormatter check passes when overlong lines are not split by JuliaFormatter, i.e. when the overlong lines are comments, docstrings or some weird constructs that cannot be split properly to fit into the limit. |
But what I mean is that e.g. a string can be split (by a human) so if CI fails it would be something you would have to fix, but Runic wouldn't do it for you. |
Yes, I just wanted to say that this will require some complex logic as well (could this line be split?). |
Is this planned soon? For me, one reason to use an automatic formatter is that auto-formatted code immediately matched my expectations. Having to manually reformat lines that are too long defeats this purpose a bit.
Also, without automatic line breaks, we would end up with PR comments like "please split this long line", which were the main reason why we introduced automatic formatting in the first place. A strict line length limit in the CI check wouldn't work, as some lines (like comments containing long URLs) might not be possible to break.
A really cool feature would be what JuliaFormatter does in the SciML style:
It's not a greedy line break at the point where it's exceeding the limit, but there is some balancing logic going on to avoid this:
some_function(some_argument, another_argument, foo, bar, more_foo, more_bar, even_more, more, more, more)
The text was updated successfully, but these errors were encountered: