StyLua icon indicating copy to clipboard operation
StyLua copied to clipboard

`collapse_simple_statement` collapses functions inside conditionals

Open PepeElToro41 opened this issue 1 year ago • 0 comments

If you have collapse_simple_statement for conditionals and you add a function as the statement

if bar then
    return function()
        foo()
    end
end

it will collapse the function as it's considering the function as a simple statement. So it ends up like this:

if bar then return function()
    foo()
end end

This will also happen if the function is provided as an argument

this:

if bar then
     return Array.filter({}, function()
          return true
     end)
end

formats like this:

if bar then return Array.filter({}, function()
     return true
end) end

Probably functions shouldn't be considered as a simple statement

PepeElToro41 avatar Oct 04 '24 09:10 PepeElToro41