texstudio
texstudio copied to clipboard
Collapse and expand in one function (with one shortcut)
Describe the feature and the current behavior/state
Right now, "View > Collapse > Nearest Block" allows collapsing a block and "View > Expand > Nearest Block" allows expanding a block. To merge both functions into one collapse/expand ("View > Expand/Collapse > Nearest Block") would be useful. The user does not need to have separate shortcuts for expanding and collapsing. This saves time and one shortcut slot.
PS: This might be useful not only for block folding but in general.
Who will benefit with this feature?
All users that want to collapse/expand blocks frequently.
Current behavior: The cursor stays in the same line, even when this line gets invisible (i.e. the line is not the first one of the block) because the block containing the line gets folded.
An implication of this is, that repeating action "fold nearest block" folds the next outer block, but when the action is "change the folding state" then the currently folded block gets unfolded.
Even when folding a block would move the cursor to the first line of the block, it is not clear if you want to unfold the current block or if you want to fold the outer block. With the current state you can decide what should happen. When you want to shrink down a chain of blocks then in your case you would have to move the cursor up one line in each step.
So I think that your feature request can't be fulfilled.
@octaeder Thank you very much for this remark! I have not thought about this.
One possible solution might be that only the lowest level gets folded/unfolded when the cursor is in the first or other lines of the block. When moving the cursor up, it is in the block above (the outer block) that gets folded. From my point of view, I think it is very cumbersome to use all those different functions for folding/unfolding. Also, to fold an outer block before folding the inner block seems unintuitive. One function for unfolding/folding would be much easier. For folding the outer block, I would simply move the cursor to one line above.
it is not clear if you want to unfold the current block or if you want to fold the outer block
For this collapse/expand function, it should only be the current block. For folding the outer block, you could move the cursor up one line. Using arrow key up in a folded block should always result in moving the cursor to the first line of block - 1.
So, it would always be collapse/expand the nearest block (similar to clicking the small triangle icon on the left).
note some further information in #3241