Hello,
thank you for your feedback on the collapsible region feature.
To answer your question, the collapsible regions are recognized as the user types. If the user introduces an inconsistency in the code (let's say deletes a curly brace) which makes a region invalid, that region will disappear. And if it was previously collapsed, it must be expanded.
Also, regions are expanded in other cases, when for example a breakpoint is hit or text search hits inside a collapsed region.
If you are having a real problem with your regions expanding on their own, please give us more details and we will look into it.
Best regards
LDP