vscode-yaml
vscode-yaml copied to clipboard
Can not fold YAML map comment
Describe the bug
When I try to fold a map with a comment in the YAML extension enabled, I get the problem that I can't fold it.
Expected Behavior
This is an unfolded text example.

This is a text that is folded above example.

Current Behavior
This is an unfolded text example.

This is a text that is folded above example.

Steps to Reproduce
- open a YAML file
Environment
- Windows, Mac
- YAML 1.7.0
Related Issue
- https://github.com/redhat-developer/vscode-yaml/issues/737
We do not have a good way to know if a comment block is intended to be folded with which pair. For instance, in the example given, we only expect #d to be folded with c because it was indented. Perhaps indentations of the comments are how we recognize folding boundaries.
Seconding this feature request and @gorkem 's analysis that it's not trivial to identify when comments belong to a folding range or not. However as stated I believe that the indentation of the leading # is what you'd want to use to guide the folding range. When selecting some indented key-value it places keeps the indentation intact so the "add line comment" commands would function correctly with the folding ranges computed as suggested.
In the old VSCode default specifications, the folding range was determined by indentation, so if the indentation is deeper, I think it is better to judge that it belongs to the element above.