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?
Once you've opened Visual Studio Code, just press alt + space and the system menu will appear, then you just have to select the Always on top option.
Hit Tab multiple times until your cursor is at the proper indentation. Navigate up to a line with proper indentation, press End , then press Enter . Click your mouse to the right of a properly indented line, then press Enter . Press Ctrl + ] repeatedly to indent the empty line.
To turn on or turn off the Auto Save feature in Visual Studio Code, go to File and click on Auto Save from the drop-down menu: The steps are completely the same in Windows and macOS. If you want to config the Auto Save behavior deeper, go to: Mac: Code > Preferences > Settings.
For me it was the prettier plugin :(
Here is the closed issue: https://github.com/prettier/prettier-vscode/issues/408.
At the moment, there doesn't seem to be a fix.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With