The autocompletion of if and while statements do not account for comments

Explanation

Pressing ENTER after writing the beginning of an if statement or a while statement (i.e. if Value, while Value) results in the remaining keywords (then, end; do, end) being added directly after the initial statement. This is the intended behaviour.

However, this behaviour occurs incorrectly when a comment (--) is added directly after the Value part of the initial statement. Instead of placing the then/do prior to the comment, it is placed after the comment, resulting in then/do being added as part of the comment.

Example 1 in the video below shows the behaviour occuring with a while Value, Example 2 shows the behaviour occuring with an if Value, and Example 3 shows that pressing ENTER while the cursor is after the autogenerated end keyword causes the then keyword to be recreated.

Reproduction

  1. Add the beginning of either an if or while (if Value, while Value) statement to a script.
  2. Add a comment after the Value (--, -- TEXT, etc.)
  3. Press ENTER while the cursor is located after the comment (if the cursor is located prior to the comment, then the comment is just moved down a line, with no autocompletion occuring).
  4. Observe the incorrect placement of then / do.

Device Info

Operating System: Windows 10
CPU: Ryzen 5 3600
GPU: GTX 1650 Super
RAM: 16GB @ 3600MHz

5 Likes

Thanks for the report! We’ll follow up when there’s any update on the issue.

2 Likes

Thank you for the report, we’ve added this issue to our bug queue.

2 Likes

Hi this is working as designed (and happens in other editors). Just let us know if you have any questions, thanks again!