EmmyLua / IntelliJ-EmmyLua

Lua IDE/Debugger Plugin for IntelliJ IDEA
https://emmylua.github.io
Apache License 2.0
1.74k stars 293 forks source link

Updated SpacingBuilder to allow code next to if statement if preferred #400

Closed pouwelsjochem closed 2 years ago

pouwelsjochem commented 3 years ago

Because of the lineBreakInCode() in the 'befores' we still get the same behavior as behavior which automatically aligns the 'end' for example. But comments are not automatically moved to the if's body

    local t = {}
    function t:a() -- this comment was always allowed since there was no code in the body

    end

    function t:b() -- this comment is now allowed
        local randomNumber = math.random(10)
        if randomNumber < 2 then -- this comment is now allowed
            return 1
        elseif randomNumber < 4 then -- this comment was always allowed since there was no code in the body

        else -- this comment is now allowed
            local test = 1
        end
    end

    return t