More robust script formatter.

If there's a bug, it should now no longer prevent the script editor from opening.