This makes the script editor really hard to use for any but the most basic cases because if you hit carriage return, the cursor is not put on the new line, it is placed on the line below the new line. So every time you press return, you have to fix the cursor location before you can type the new line.
Load the attached script
Go to the If line and put the cursor at the end.
Notice that a new line was added, but the cursor is not before EndIf and not on the new line