Open FALLAI-Denis opened 3 years ago
The shortcuts Ctrl+K Ctrl+<niv>
are already working fine.
The folding ranges are provided to VSCode as expected by it. There is no level in the spec, there are calculated by VSCode.
This extension will only provide folding ranges. Changing the visual behaviour would require another extension, if possible.
My request was not about using the Ctrl+K Ctrl+<niv>
commands which actually work well (although behaving confusingly).
My suggestion concerned the possibility of having visual feedback on the scope of a folding, for example by adding information in the gutter. Something like what I tried to depict below:
The formalism is just for illustration and could take a whole other form.
If VS Code does not manage a level in the folding, nor the "Explicit Folder" extension currently, perhaps it would be possible to associate an information with each declaration of markers in the "folding" settings, and that this information then be used for display in the gutter. It would only be by pure convention that this information would be a level, it could also be any information.
The "Explicit Folder" extension could have a set of predefined icons, or give the possibility to provide your own icons, that we could associate with a group of markers, for display in the gutter.
For example by adding a "decoration" property to each group expressing a folding. Which could give:
"folding":
{"cobol": [
{// Division
"separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?=\\s+(?i:DIVISION))"
,"strict": false
,"decoration": "icon01.png"
,"descendants": [
{// Section
"separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?=\\s+(?i:SECTION))"
,"strict": false
,"decoration": "icon02.png"
,"descendants": [
{// Paragraph
"separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?!\\s+(?i:SECTION|DIVISION))"
,"strict": false
,"decoration": "icon03.png"
,"descendants": [
{// Page eject
"separatorRegex":"(?<=^.{6})\\/"
,"decoration": "icon04.png"
}
]
}
]
}
]
}
]
}
Confer DecorationRenderOptions.
I agree that it can be helpful.
VSCode manage the levels of folding since you can collapse the foldings based on their level. But a folding range provider can't and doesn't need to provide it (VSCode can combine folding ranges from several providers. So a range from a provider can be a sublevel of a range from another provider).
Here the definition of a range:
class FoldingRange {
start: number;
end: number;
kind?: FoldingRangeKind;
constructor(start: number, end: number, kind?: FoldingRangeKind);
}
Me too, I would like to change how to display a folding, like adding the number of lines when the folding is collapsed. If I had searched how to do it, it would have been the subject of another extension.
I modified my issue to no longer refer to a range, but just to associate visual information with each folding point.
I propose to leave this request pending and mark it as an "enhancement".
Describe the issue
With hierarchical folding (separator / separatorRegex + descendants), it becomes difficult to see the scope of a folding.
Would it be possible to materialize this scope visually at the level of VS Code?
Either by using particular folding markers, for example by using color codes (but I don't think that is possible).
Either by adding information in the gutter: a level number (which then makes it possible to use the commands
Ctrl+K Ctrl+<niv>
), or a colored line extending over all the lines concerned by the folding.To reproduce
Code Example
Settings
Expected behavior
See the scope of a folding before making it.
Screenshots