Open deathaxe opened 1 year ago
Related with #1064, which requests the modifier for fold buttons.
@deathaxe Also is it possile to keep cursor always in view after (un)folding? Currently the viewport will jump around after (un)folding which makes it a bit annoying having to find where the cursor is in a rather long document.
Possibly related: https://github.com/sublimehq/sublime_text/issues/5622
btw I remember it used to do it in a context-aware way, say I have three functions (A, B, C), fold all functions, move cursor to function B, press cmd-k-2 will just unfold function B, but now all three functions will be unfolded (hence pushing away the cursor from viewable area, a.k.a viewport jumping wild issue)
... is it possile to keep cursor always in view after (un)folding?
I can't tell what's possible, just a (power) user not a dev.
The main reason for caret "jumping" around is, ST selecting regions unfolded via key bindings (see #5797). I also find it rather noisy and confusing, but this has been the default for ages accoring to the devs.
But that's probalby a different issue not related with how multiple folded regions in a single line could be unfolded.
... but now all three functions will be unfolded ...
Yes, this behavior has changed. Only selected regions being unfolded/folded was a bug according to devs.
ST now folds all regions by desired level, except the one(s) a caret is within.
Only selected regions being unfolded/folded was a bug according to devs.
Sigh, if only there is a flag in the configuration file to restore this bug/feature
, thanks for making things a bit clear @deathaxe...🥹
@BenjaminSchaaf could you please consider making this happen? (maybe by simply cherry picking from old codebase will do the trick?) 🙏
ST4145+ provides a setting to enforce old folding behavior.
// The style of code folding to use
// - "auto": Use whatever the default is for the syntax in use
// - "force_indentation": Always use indentation-based code folding
// - "scope_only": Only allow syntax-based code folding
"fold_style": "auto",
Problem description
Considder following code snippet.
Folding method's parameters and body may end up in:
Unfolding via fold buttons unfolds both regions.
Unfolding via key bindings
ctrl+shift+]
works only, if caret is directly next to one of folded regions.Preferred solution
Unfolding via fold buttons should unfold regions one by one beginning with the last one, maybe by default or if a modifier key is pressed.
Example:
left click
unfolds all regionsctrl+left click
unfolds regions one-by-oneKey binding should unfold regions one by one beginning with the last one in the same line caret is located in. Maybe a new argument for
unfold
command can be introduced to control its behavior.Valid values for
strategy
:"all"
: unfold all regions of current line no matter where caret is located"single"
unfold only the region the caret is located at (current behavior)"left_to_right"
: unfold regions of current line one-by-one beginning with the left-most one, no matter where caret is located"right_to_left"
: unfold regions of current line one-by-one beginning with the right-most one, no matter where caret is locatedAlternatives
It should at least be possible to unfold regions of a line without moving caret exactly to the front of a folded region.
Additional Information
No response