If 'v' represents a start fold marker, and '^' represents and end fold marker, then creating an unindented (column 0) function looks like this:
v function foo( )
print( 'hey' )
^ end
So far, so good. Now, suppose I block comment out this function (without indenting it):
v --[[
v function foo( )
print( 'hey' )
^ end
^ ]]
This looks correct, but if I toggle the first folding marker, I get this:
> --[[•••
^ ]]
In other words, the folding looked for the first end marker that was at the same depth as the start marker, and (incorrectly) used the 'end' line. Instead, I propose that it should scan down and when it sees the second start fold marker at the same depth, add 1 to a counter; when it sees the first close fold marker at that depth, it checks the counter...since it is non-zero, it subtracts one. Finally, when it sees the last fold marker, and the counter is at zero, then it uses that as the correct, paired end fold.
P.S. What's the netiquette/guideline regarding attaching screenshot images inline to an email message to a mailing list, when that mailing list is almost certain to be used solely by MacOS users, who likely are using a Mail program that would support them? Would have been easier than the ascii art above (which itself is non-plain text, so I'm violating another common mailing list rule there).