Packages icon indicating copy to clipboard operation
Packages copied to clipboard

[Lua] Reindenting does not work after commenting on a line

Open 132ikl opened this issue 9 years ago • 7 comments

After you add a comment to a line in lua, it no longer reindents correctly. This only happens with lines that have comments on them, and it messes up all future lines that would otherwise be indented.

Example: https://embed.gyazo.com/c4e1c0b0256129d349ba7de997cc4cdf.png

132ikl avatar Jul 13 '16 19:07 132ikl

It seems comment detection is a bit over-eager as the commit on the same line prevents any indentation increase from happening, even if the comment is not entirely on its own line. Looks very related to https://github.com/SublimeTextIssues/Core/issues/1271.

If I start out with

function test()
if a == "abc" then -- comment here
for x, b do
stuff
end
end
end

and run the reindent command, it changes to

function test()
if a == "abc" then -- comment here
    for x, b do
        stuff
    end
end
end

Whereas, if I start with

function test()
    if a == "abc" then -- comment here
    for x, b do
    stuff
    end
    end
end

it correctly indents to

function test()
    if a == "abc" then -- comment here
        for x, b do
            stuff
        end
    end
end

FichteFoll avatar Jul 14 '16 11:07 FichteFoll

Oh, silly me - I was trying with the Packages/Default/Indentation Rules - Comments.tmPreferences file overridden to fix it, so of course it worked for me - apologies ;) I can confirm the same, but it is not a problem with the Lua package, it's a problem with the Core ST3 indentation system. Similar problems with Python etc.

keith-hall avatar Jul 14 '16 11:07 keith-hall

If it's a problem with the core, should I go mark it as a bug there?

132ikl avatar Jul 14 '16 15:07 132ikl

I saw this was open when I searched for Lua issues just now, this has been fixed since the rehaul of the entire Lua SH

RheingoldRiver avatar Nov 14 '19 23:11 RheingoldRiver

I saw this was open when I searched for Lua issues just now, this has been fixed since the rehaul of the entire Lua SH

Seems still broken for me. (Not that I'm a Lua user... yet.)

function test()
if a == "abc" then -- comment here
for x, b do
stuff
end
end
end

indents to

function test()
if a == "abc" then -- comment here
for x, b do
    stuff
end
end
end

michaelblyons avatar Dec 09 '24 19:12 michaelblyons

Yeah, indentation rules depend on scopes on eol. As indentation rules' selector excludes comments ...

deathaxe avatar Dec 09 '24 20:12 deathaxe