I've been bumping into this "bug" over and over again and its starting to pester me. For whatever reason, and I've noticed it happens more when you copy paste things in the script editor, I get errors regarding indentation.
As you can see, the ParentFolder function needed to be spaced over a bit.. There is absolutely no reason for it to need to be indented like that, NONE WHATSOEVER.
Is this going to cause issues for production? I have bits and pieces of code like this in other projects as well. If one day this bugged is fixed are our current projects going to crash and result in loss of production?
The secret is to highlight the entire code block with the desired indentation:
Then, in the area where it is to be pasted, make sure there is no indentation at all:
When it's done this way, the indentation doesn't get messed up:
Copy the entire block even if the indentation of the code that is being copied doesn't match the indentation level that it will need when pasted because the original indentation will be preserved. In this way, the pasted code block can simply be highlighted and moved to where it needs to be with tab or shift-tab.