Vscode: [Bug] Re-Indenting is (completely) broken in lua

Created on 22 Jan 2019  路  14Comments  路  Source: microsoft/vscode

Issue Type: Bug

When re-indenting while using Lua everything is put on indent level 0, all existing indents in a file are removed and put on the same level.

In other languages it seems to only work when it's based on brackets/parentheses, but even in XML for example nothing seems to get indented.

Very important is, is that I'm not talking about the formatting code feature, but just the "Reindent Lines" feature, which I have been using a lot.

VS Code version: Code - Insiders 1.31.0-insider (e9bb33f09599753150be897ab81126a620e53b94, 2019-01-21T06:19:35.291Z)
OS version: Windows_NT x64 10.0.17763

bug editor-autoindent verified

Most helpful comment

If anyone wants a quick hack to fix it, all you have to do is

  1. Open Notepad as admin.
  2. In the Notepad open dialog:

    1. Go to your VS Code installation folder

    2. Go through the resources/app/extensions folders.

    3. Find the lua folder

    4. Open language-configuration.json

  3. Find the increaseIndentPattern line. (Do not edit the decreaseIndentPattern line.)
  4. Erase the ^\\s* at the beginning of the string.
  5. Save and exit Notepad.
  6. If VS Code was open, reload the window.

Now indentation should be better!

All 14 comments

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

Not a duplicate

Now this bug is present in the normal version of VS Code instead of just insiders, which (honestly said) sucks. Now working on my projects became much harder than it was before.

This is also messed up on my installation. I am using no settings that change auto-indent. All ->s are tabs.

if statement auto-indentation is wrong.

I have a simple if statement.

-> -> -> if thing then|

...then I press enter.

Expected:

-> -> -> if thing then
-> -> -> -> |

Got:

-> -> -> if thing then
-> -> -> |

end statement auto-indentation is really bad.

After that, I want to close off this if statement.
I type en.

-> -> -> if thing then
-> -> -> -> -- a bunch of stuff
-> -> -> -> en|

Good... Means nothing, but so far, so good.
I type the final character, d, and...

Expected:

-> -> -> if thing then
-> -> -> -> -- a bunch of stuff
-> -> -> end|

Got:

-> -> -> if thing then
-> -> -> -> -- a bunch of stuff
end|

I found the source of the bug. In my copy of VS Code, I undid the change done to fix #63407. Then, everything worked perfectly.
Unfortunately, this does reintroduce the bug it supposedly fixed. I don't know RegEx very well, so I can't solve this issue.

This bug makes my programming difficult and I hope to fix it as soon as possible.

If anyone wants a quick hack to fix it, all you have to do is

  1. Open Notepad as admin.
  2. In the Notepad open dialog:

    1. Go to your VS Code installation folder

    2. Go through the resources/app/extensions folders.

    3. Find the lua folder

    4. Open language-configuration.json

  3. Find the increaseIndentPattern line. (Do not edit the decreaseIndentPattern line.)
  4. Erase the ^\\s* at the beginning of the string.
  5. Save and exit Notepad.
  6. If VS Code was open, reload the window.

Now indentation should be better!

i submitted a PR, hope we get our indentation back asap. if you want a quick hack that also solves the comment intendation bug that started this, use @TheV360's instructions with the regex from #68978

Thank you @WorldofBay , fixed via #68978

Good to see a recent fix to this, however, it is still broken on my side.

I tried to apply the fix on my language-configuration.json, tried both with and without the ^\\s* pattern at the start, but it still doesn't indent correctly.

here's a test code I did, else decrements indent improperly, as well as end in functions in tables:

function test()
    function test()
        if(test) then 
    else
    end

    end
end

local test = {
    test = function ()
end
}

edit:
after a few editing, found that the Lua extension I use (Lua Plus) has a separate language-configuration, and so I tried editing it and the indent works now.

Okay, this is marked as closed but I still have the problem. Are there any news regarding this topic?

Okay, this is marked as closed but I still have the problem. Are there any news regarding this topic?

It works properly on my side. Do you have any Lua extensions like Lua Plus which highlights syntax?

are you using insider? if not, the fix is not published yet. expected release date is today, however the checklist on #69177 is not fully done yet, so it might also be slightly later.

Ahh, I'm not using the insider build. Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukehoban picture lukehoban  路  3Comments

curtw picture curtw  路  3Comments

philipgiuliani picture philipgiuliani  路  3Comments

trstringer picture trstringer  路  3Comments

chrisdias picture chrisdias  路  3Comments