Open Takakiriy opened 2 years ago
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.
FYI, Notepad++ has done this in a similar way to @gorkem's suggestion. In case it helps, here are more details on their method:
a:
b:
- c
d:
e:
becomes commented as
# a:
# b:
# - c
# d:
# e:
and the lines with a:
and b:
can fold everything under (until the next key) to become respectively
# a:
# e:
and
# a:
# b:
# d:
# e:
Meanwhile, the default comments in VSCode seem to be applied to the level of the least indented line.
a:
# b:
# - c
# d:
# e:
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
Environment
Related Issue