Please post your code using code tags so that it can be copied
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
I think that in this case it was useful to demonstrate the experienced issue. I do not think that there is a way to copy a folded function without it being unfolded when pasted.
Me too. It is an automatic action to get the code in my preferred format
Sometimes I also absentmindedly do Ctrl+T on code in the forum. Needless to say it doesn't work, or to be precise it does what it is designed to do in Chrome which is to open a new tab
As to the fact that the code posted did not exhibit the problem after formatting it, that would have lead to a discussion about what he/she was doing differently than you and I and we would have got there in the end