How to keep code-folding on save in Visual studio code

Viewed 7842

I am working on some fairly large files in Visual Studio code and to save time I fold away functions and scopes, that I do not want to see. Everytime I save, which I do fairly often just out of habit, all the folds expand again and the current position on screen changes.

Since the only settings I could find were:

"editor.folding": true,
"editor.showFoldingControls": "mouseover",

the question is: How can I keep my folds upon saving?

4 Answers

Thank you for bringing up the extensions Mark. It was indeed an extension: lonefy.vscode-js-css-html-formatter.

Once this was disabled, the folding kept its state after saving.

Had the same issue and it turned out to be the sort-imports extension. Removing it fixed the issue.

For anyone that comes across this like me, I didn't have prettier, sort-imports, or lonefy. I was able to resolve by updating the 'folding strategy' setting from 'auto' to 'indentation' and it kept my folds persistent through saving and particularly in my case deploying code using the Salesforce CLI extension.

Related