Parenthesis in strings are auto-closed incorrectly

If I write this line of code

if top == "x" then

and I press enter, Studio will automatically create the end after the cursor:

if top == "x" then
    -- cursor now here
end

I wrote this line of code:

if top == "(" then

When I press enter at the end of the line, it gets completed as this:

if top == "(" then
	-- cursor now here
)

The Script editor incorrectly reads the string literal as code, and inserts a phony brace, and no end.

1 Like

Thanks for reporting this. I’m working on this right now.

Are there any other edge cases where this occurs? I think there are, but I don’t remember.

1 Like

This can occur with do (while and for) and then any time there is a parenthesis in the line except for when the parenthesis is enclosed in a ‘multiline’/block comment.


Also, there’s this:

while --[[]] do

Becomes

while --[[]] do

]]

Same with if and other do if --[[ is anywhere on the line.
This really isn’t that important though, I think. I’ve barely ever seen code use a ‘multiline comment’ in the middle of a line like that, but it’s a bug anyway with similar behavior to the parenthesis one so I figured it’s worth knowing about.

1 Like

Thanks! I’ll handle those too!

1 Like

Today I noticed another incorrect completion.

Vector3.new(0, a(),

gets completed as

Vector3.new(0, a(),
    | -- cursor here
end

This will also be fixed with the next update (once we turn on the fix).

1 Like