Inline table and function opening causes double auto-indent

Yeah, I know, that title is a mouthful. I’m not sure how else to word it; I’ll just show what happens.

I’ve had this problem for quite a while now, but couldn’t figure out what was causing it. If you open up a table and a function in the same line, their auto-indent “stacks”, and turns into a double indent. This is very annoying at times.

In this first example, I’m just opening a function block, so everything indents correctly:

But if I want to wrap the pcall's return in a new table, this happens:

Uh oh. The automatic indenting seems to stack and mess it all up. Very ugly. Could we get this fixed soon?

1 Like

I think you can change your indentation rules to Relative in studio settings.

2 Likes

Seems like an issue you can fix by going into Settings > Studio > Script Settings > Auto Indent Rule, and not a studio bug itself.

Image of what I meant:

image

^ That changes if you want an auto indent or not but you can switch it to off if you want normal indent or not.

2 Likes

Thank you very much! This worked; I never knew about these settings.

Hey Saltscape,

Sorry for this unexpected absolute indenting. This is a bug we should fix last week. Do you still see this issue when the Auto-indent rule is absolute?

1 Like

Yes it does! Though when set to Relative, everything seems to work fine. I was asked for some sample code of the issue, so here it is:

pcall(function()
	print("This is fine.")
end)

local pcallReturn = {pcall(function()
		print("Ack! This is wrong!")
	end)}

Thanks for reporting this :grinning: You get 2 indent level at second line because both “{” and “function()” are indentable keyword. We actually suggest user to give new line after table symbol “{” if there is function within it.

local pcallReturn = {
    pcall(function()
	    print("Ack! This is wrong!")
    end)
}

But I think we should also help user to split these indentable symbol automatically. It’s planning feature.

1 Like

Good to know, that makes sense. I’ll do that instead in the future. Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.