You may notice that after saving code, any sections previously collapsed in the editor automatically expand. This happens because JavaScript formatting is enabled by default, and when the code is automatically formatted upon saving, the editor refreshes and expands all collapsed sections.
To keep collapsed sections closed after saving, disable the auto formatting feature:
This will prevent automatic reformatting and help maintain collapsed sections as you left them.