IntelliJ-EmmyLua icon indicating copy to clipboard operation
IntelliJ-EmmyLua copied to clipboard

Unable to place inline comments in certain scenarios

Open pouwelsjochem opened this issue 4 years ago • 1 comments

Environment(环境)

name version
IDEA version 2020.3
EmmyLua version 1.3.5
OS macOS Big Sur

What are the steps to reproduce this issue?(重现步骤?)

Have a file with the following content and then reformat the code.

local t = {}
function t:a() -- this comment will stay the same
end
function t:b() -- this comment will be reformatted to the next line
    local randomNumber = math.random(10)
    if randomNumber < 2 then -- this comment will be reformatted to the next line
        return 1
    elseif randomNumber < 4 then -- this comment will stay the same
    
    else -- this comment will be reformatted to the next line
        local test = 1
    end
end
return t

What happens?(出现什么问题?)

Some comments will be reformatted to new lines.

What were you expecting to happen?(期望?)

Being able to configure the Lua Code Style to prevent the comments in mentioned file being located on new lines.

Any other comments?(其它说明)

I could be wrong, but it looks like comments want to 'stick' to their owner. Because the comments will only be reformatted when there's a line of code on the next line.

I'm willing to make a pull request myself, but I have no idea what part of the code makes these reformats, so if you could guide me into the right direction that would be great, I could add a settings to optionally disable this behaviour.

pouwelsjochem avatar Dec 26 '20 19:12 pouwelsjochem

Fixed this in #400

pouwelsjochem avatar Dec 27 '20 18:12 pouwelsjochem