LuaFormat icon indicating copy to clipboard operation
LuaFormat copied to clipboard

never seems to indent anonymous functions properly when used as pars to another function (higher order function)

Open RichardEllicott opened this issue 6 years ago • 1 comments

it can NEVER seem to handle anonymous functions like:

if pcall(function () print('test1') error() end)then print('test2') else print('test3') end

this is how lua format will make this look, making all the subsequent nesting screw up:

https://gist.github.com/Ri…/ceb10fd1ed1ce1691756bda96699342a

thank god this actually formats okay mind:

tableOhFunctions = { thingy1 = function () print('blah') end, thingy2 = function () print('blah') end, }

so long as i make sure them "end" statements go on the next lines

However, since "pcall" with an anonymous function is lua's equivalent to try and catch, this is driving me crazy!

RichardEllicott avatar Jul 21 '18 11:07 RichardEllicott

First of all, I'm sorry for not replying you in time because I have been too busy recently. Thank you for providing me with the test code. This plugin is optimized for code placement and doesn't intelligently recognize code blocks, such as anonymous functions. I've been thinking about how to make it smarter. Maybe I'll rewrite it in a different way. :)

floydawong avatar Aug 08 '18 03:08 floydawong