"Collapse Fold" vs "Collapse Fold Recursively"

I’m trying to figure out the difference between the commands “Code: Collapse Fold” and “Code: Collapse Fold Recursively”. Using key bindings, I have assigned different keyboard shortcuts to each of the two commands. Consider a test file in which folding is working properly:
0001
…0002
…0003
…0004
0005
…0006
…0007
…0008
(I am using periods here to indicate spaces, because when I try to use spaces and apply the “Preformatted text” command in the WYSIWYG editor on this forum page, it only works for the last four lines and not all of them.)

If the edit cursor is currently on the second line and I execute the command “Collapse Fold Recursively”, I expect the two more-indented lines immediately underneath it (3 and 4) to be folded up into the current line, and it does indeed result in:
0001
…0002

0005
…0006
…0007
…0008
The horizontal line extending all the way across the editor window of course indicates that there are hidden lines folded within it.

I wasn’t sure what to expect with “Collapse Fold”, but assumed it would be something different, since there are two separate commands. But when I execute “Collapse Fold”, the exact same behavior occurs.

Anyone know what the difference is – or is supposed to be – between these two commands? (I of course googled it first, but found nothing.)

I think the difference should be that when you collapse recursively e.g.

0001 {
    0002 { <- this one
        code
        0003 {
            0004 {
                0005 {
                    code
                }
            }
        }
    }
}

And then uncollapse 0002 again, you’ll get

0001 {
    0002 {
+       code
+       0003 [collapsed] {0004[collapsed] -> 0005[collapsed]}
    }
}

And with non-recursive collapse (with the same tree):

0001 {
    0002 {
+       code
+       0003 {
+           0004 {
+               0005 { 
+                   code 
+               }
+           }
+       }
    }
}

0004 and 0005 were not collapsed because of non-recursive collapse (they might be collapsed by the user but the idea is that their state is unchanged). If it’s not working in the same way, I think it’s a bug and you should report it on the bug tracker :slight_smile:

Thank you for your awesome reply. Also, I like that you included the braces, which I should have done, as well as the extra non-brace lines, such as the “code” immediately after 0002. So I improved my example text:
0001 {
…0002
…0003 <-- edit cursor here {
…0004
…0005 {
…0006
…0007 {
…0008
…}
…}
…}
}
I then tried both of the commands, but this time also paid attention to the results of what happens when all of the lines are subsequently expanded (which I had neglected to do earlier). It works exactly as you described it should.

As before, I resorted to using periods instead of spaces when posting indented text in this forum’s WYSIWYG editor. How are you able to preserve indentation when submitting your posts?

I use code fencing.

Excellent. Thanks. I was falsely assuming that we only had available the tools displayed in the WYSIWYG toolbar.