Pressing enter at end of if statement inserts "end" keyword, even if it is already there, if a varible is set with two if statments

If the current selection is after the “then” keyword in an if statement, pressing enter will always insert an “end”, even if it is already there.

Before hitting enter:
image

After hitting enter:
image

Edit: This seems to be caused by having a variable set with two if statements anywhere in the script, as shown here:

Expected behavior

The end should only be put there if it is not there already.

3 Likes

I wasn’t able to reproduce this but was able to when the statement before the selected was missing its end.
image
image

1 Like

I did some experimenting and I was able to find the cause of this issue. If you set a variable with the structure x = if y then z else w, you can do that within itself, like this

(yes, this is terrible code)

the line setting the primarypart causes the issue. it also messes with studio formatting so that auto-formatting the document will indent everything after that line.

Hi, thank you for filing this ticket. This is a known issue with our formatter and we’re in the process of collecting feedback for similar issues under this thread.

Please let us know if you have any similar issues under that thread.

Thank you!

2 Likes