-
Notifications
You must be signed in to change notification settings - Fork 79
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
Function calls not hanging when over column width #368
Comments
Another angle, I'd expect this to act the same as the examples above: foo.bar(--[[-------------------------------------------------------------------------------------------------------------]])
.returns()
foo
.returns()
.bar(--[[--------------------------------------------------------------------------------------------------]])
.way()
.longer()
.chain()``` |
Another issue like this: foo
.bar('------------------------------------------------------')
.returns('-----------------------------------------') -- some comment This is wrapped on one line and then it exceeds the column limit because of the comment. |
Out of interest, what kind of context do you have which chains function calls like this, rather than chained method calls ( When I originally implemented call hanging, I assumed that dot index |
The unit testing framework https://olivinelabs.com/busted/ uses chained function instead of method calls. assert.spy(s).was.called_with(match._)
foo.on_call_with(1, 2, 3).returns("foo", "bar") |
I'm thinking of making I'm wondering if there are any disadvantages for doing this - do people prefer dot index calls to stay inlined? Once noticable disadvantage of doing it would be for something like Promise.new(function(resolve, reject)
local foo = "bar"
resolve(foo)
end)
:andThen(function()
local x = 1
local foo = "bar"
return true
end) it would now turn into Promise
.new(function(resolve, reject)
local foo = "bar"
resolve(foo)
end)
:andThen(function()
local x = 1
local foo = "bar"
return true
end) But is this actually a disadvantage...? The alignment actually makes it look better imho. A way to resolve this could be to special case the |
I agree on special-casing |
Incredibly sorry about the delay in sorting this out. Should be fixed in #470 and available in the next release |
For the input below, I expected that the formatted output kept the same amount of lines:
However, StyLua formatted it like the output below, where each function call chain is joined on a line. The lines are longer than the column limit of 120, and that doesn't read nice.
I'm posting it here, because it looks like a duplicate of this issue.
Originally posted by @TjeuKayim in #78 (comment)
The text was updated successfully, but these errors were encountered: