-
Notifications
You must be signed in to change notification settings - Fork 85
Multi-line chained functions are merged onto a less-readable single line, but under the column width #339
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
Comments
Another idea is to always break when a function is chained directly to a previous one. So always split between Although, I'd generally prefer not to split |
Another option could be not breaking on single |
As I mention in #78 (comment), I want to try and avoid relying on input code to determine how to format something. I do agree though that it does make it less readable though, so might be something to improve.
This is an interesting suggestion, and is probably a good alternative to relying on the input. Might be something to look into |
That's close to what I was thinking with my second comment, but should self:Func() args get broken too? Given:
I think break if multiple : would result in:
But break every ): would give:
|
This is true, I didn't consider nested chains within calls - I'm not sure I like it so expanded like this.
I assume this means like leave the first chain intact, but not the rest? This is a interesting idea, we actually discussed it earlier in #123, but there was an example which made this look quite odd: #123 (comment) |
What if our rule was "break every That would maintain the format of my previous examples and match the format of the "good" example on 123. "is multi line" seems like a significant enough case to justify specialized behaviour. |
I think the ideal option for me would be to have an option to only change the line if it is over the specified column width. So it would introduce line breaks if it is too long like it does now, but never join lines if someone went through the trouble of formatting them as multi-line statements. |
What is the status of this proposal? I am in favor of it. -- From
local a = {
"a", "b", "c" }
-- To
local a = {
"a",
"b",
"c",
}
-- No change in this one
local a = { "a", "b", "c" } |
I don't think that's likely:
However, I think the heuristic "break every
Compared to the current (0.17.1) behaviour:
|
Related to #78, chained functions are merged onto a single line which makes them less readable -- even if a short line.
Before
After
stylua test.lua
Similar to my proposal on 78, I'd suggest we preserve chain line breaking. Or maybe an option to always break before function chaining?
The text was updated successfully, but these errors were encountered: