Not sure if there is such a function already, if not, this might belong into feature requests.
How can I set the editor to remember folded parts of code upon close, so it will reappear the same way upon next open?
All I could find about folding is either fold all or fold nothing.