vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

Can not fold YAML map comment

Open Takakiriy opened this issue 3 years ago • 4 comments

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. good_unfold

This is a text that is folded above example. good_fold

Current Behavior

This is an unfolded text example. bad_unfold

This is a text that is folded above example. bad_fold

Steps to Reproduce

  1. open a YAML file

Environment

  • Windows, Mac
  • YAML 1.7.0

Related Issue

  • https://github.com/redhat-developer/vscode-yaml/issues/737

Takakiriy avatar Apr 30 '22 08:04 Takakiriy

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.

gorkem avatar May 09 '22 01:05 gorkem

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.

siegenthalerroger avatar Apr 04 '24 14:04 siegenthalerroger

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.

Takakiriy avatar Apr 04 '24 15:04 Takakiriy