Script Editor incorrectly dedents after `a[b[i]]`

Consider the following code:

function foo()
	for i = 1, 10 do
		a[b[i]] = 0| -- put cursor at end of this line, and press enter
	end
end

If you put your cursor at the end of the third line and press enter, you get this:

function foo()
	for i = 1, 10 do
	a[b[i]] = 0
	|
	end
end

where | indicates the cursor. The expected/correct result is of course

function foo()
	for i = 1, 10 do
		a[b[i]] = 0
		|
	end
end

I believe the problem is that ]] is being treated as the end of a long string, even though here it is not.
The bug also dedents end if you press return with the cursor at the end of line 4.

The script editor should not treat ]] as affecting indentation when they are matching two separated [ on the same line.

4 Likes