Even if the form editor rather than the code editor is in the foreground, the editor experts are still active and if executed, change the code without the user realizing this.
See http://www.gexperts.org/open-tools-api-faq/#editororform on how to determine that condtion.
Diff:
fixed in revision #2602