Auto Indent is affected by keywords in comments/strings

Automatic indenting breaks if a Lua keyword is contained in a comment or string. I don’t remember when this started happening, just that it’s been frustrating to write Lua source generators/simplifiers for a long time.
Keywords affected by this include then, do, repeat, function, elseif, until, end, (, ), {, and }

Here are a few examples:
Image_614

Image_632

14 Likes

This has been going on for a while and roblox hasn’t done anything about it despite it being brought up before. Really hope roblox fixes this because it’s extremely annoying in some cases.

asd

3 Likes

Hey @Tomarty - thanks for reporting! I’ve created a ticket for this and we are reviewing.

@Tomarty, @Ultimate_Table - we’re putting some dedicated effort into improving the Script Editor so please report any other issues or continued frustrations!

2 Likes

Studio looks through all code for keywords in the script editor to determine where to automatically add script indentation. It doesn’t account for comments that are not part of any specific piece of code. This causes annoying situations when quickly writing code and you randomly an indentation.

This bug happens in the script editor and because of comments. It has been happening for as long as Studio has had an auto-indentation system.

Repro:

  1. Enter Studio on a baseplate, insert a new script (can by any script type)
  2. Paste the following script and press enter on all of the ends of each function
function CommentFor()
	-- for i = 1,50 do
end
	
	
function CommentFunction()
	-- function ok do this
end
	
	
function CommentFunctionParethensis()
	-- function()	
end
	
	
function CommentDo()
	-- do
end
	
	
function NormalComment()
	-- test
end```