How to Prevent Collapsed Sections from Expanding After Saving Due to Auto Formatting

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.

Why Does This Happen?

  • Auto format code is turned on by default in the code editor settings.
  • When formatting occurs (such as on save), the editor reloads the code view, expanding any collapsed code blocks.

How to Turn Off Auto Format Code

To keep collapsed sections closed after saving, disable the auto formatting feature:

  1. Go to Settings in your editor.
  2. Navigate to Code Editor Settings.
  3. Locate the option for Auto format code.
  4. Toggle Auto format code off.

This will prevent automatic reformatting and help maintain collapsed sections as you left them.

Jared Malan