lua-fmt icon indicating copy to clipboard operation
lua-fmt copied to clipboard

comment is move to the wrong place

Open Arpple opened this issue 6 years ago • 2 comments

running formatText on these lines

function Test()
    if a == 0 then
        print("1")

    -- a is one
    elseif a == 1 then
        print("2")
    end
end

result is

function Test()
    if a == 0 then
        -- a is one
        print("1")
    elseif a == 1 then
        print("2")
    end
end

Arpple avatar Jul 14 '18 11:07 Arpple

This also happens if you when you have a comment before the 'end' line of an if-else-end block.

Input:

if condition then
    doStuff()
else
    doOtherStuff()
    --comment
end

Output:

if condition then
    doStuff()
else
    --comment
    doOtherStuff()
end

AgentOttsel avatar Oct 15 '18 12:10 AgentOttsel

another case I found Input:

if 1 then
    doSomething()
    -- comment
end

Result:

if 1 then
    doSomething()
-- comment
end

Arpple avatar Oct 17 '18 08:10 Arpple