Vscode: Code folding no longer works by indentation

Created on 7 Apr 2018  路  6Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.22

After updates to code folding, now it is not possible to use indentation level folding.
This is still very useful as I have written an extension around the original behavior which provides a much better experience to code folding.
https://marketplace.visualstudio.com/items?itemName=dakara.dakara-foldplus

However, this extension is now broken.
I see potential options:

  • Provide an option to still use indentation level folding
  • Provide additional API's that would allow my extension to work with syntax folding. It would require API's to know the level of any particular line and the folding region.
editor editor-autoindent

Most helpful comment

There is a new setting "editor.foldingStrategy": "indentation" to get back the old behavior.

All 6 comments

There is a new setting "editor.foldingStrategy": "indentation" to get back the old behavior.

I really like the idea of having syntax-aware folding, but I think it's important to keep some of the "indentation folding logic" as well.
If you have a look at ES6 template strings, for example, they cannot be folded with the new strategy which is a no-go in my opinion and the reason I am switching back to the old strategy.
Ideally, the syntax-aware folding should go on top of of the indentation based one, so indentation based folding works the same as always with the added bonus of the syntax-aware folding.

In regards to the setting editor.foldingStrategy, thanks this is helpful; however, in #46944 it seems this may only be temporary. I would like to see some clarification if indentation folding will continue to be supported.

@T-Specht Supporting combined strategies would be great; however, not sure if that is possible. What happens when you have a conflict? Indentation folding for a line might fold differently than the folding defined for the language of the same line.

I think for my extension, I will add a command toggle to make it faster and easier to switch between the folding strategies.

@T-Specht Thinking more about the combined strategies, I'm thinking it might actually be better if there was a new commands introduced called something like Fold By Structure instead of fold by level. This would signify using the language defined folding. Then both could be used at the same time.

"editor.foldingStrategy": "indentation" is not going away.

API to access the folding level at a given line is currently not planed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

borekb picture borekb  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

DovydasNavickas picture DovydasNavickas  路  3Comments

biij5698 picture biij5698  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments