maptz.vscode.extensions.customfolding
maptz.vscode.extensions.customfolding copied to clipboard
Feature Request: only 1 region expanded at a time
Would be great to make it auto-collapse all other regions when expanding a region, maybe a per-language setting in the config file, or even more flexible it could be like "maxExpandedRegions": 2
The more I think about this, the more I think this is better done as a separate extension.
Is the maxExpandedRegions = 1
case any any different to collapse All with your cursor in the region you want not to be collapsed?
I'm not sure I quite understand what maxExpandedRegions > 1 means, especially around nested regions.
yea separate extension make sense if regions are a native part of VSC and not just part of this extension?
when expanding a region it would collapse all the others automatically, like this accordion https://jqueryui.com/accordion/ or more like this one https://jqueryui.com/accordion/#collapsible
maxExpandedRegions > 1 would mean it would collapse least recently used regions when you expanded more, I didn't know regions could be nested, I could see how that would be complicated, but even just as a boolean it'd still be convenient
Have you tried just collapsing all regions when in a region block? That effectively opens only the current region.
yea that's cool but it isn't automatic, it's more button clicks on my part
Understood. It's definitely doable. Not sure I'll get the time to do it in the near future, but I'd have thought pretty much all the code is in this extension repo. You might have to setup a background timer to look at when the cursor has changed regions. I've a vague feeling it might be a bit messy as it might collapse regions in a way that isn't particularly pleasing for the user (ie not directly tied to navigation commands). Not sure.
You'd also need to deal with multiple cursors which is another area of complexity.
I've never looked at the APIs for VSC extensions, but is there not an event called when a region is expanded?
Not sure off the top of my head I'm afraid, but I somewhat doubt it. The extension APIs aren't always amazingly fully fledged.
Even if there isn't, in theory - because it's all just javascript - you might be able to pipe into the underlying code somehow, but I've never managed to dig beyond the api.
I believe this functionality is something that should be implemented by a separate extension. I think it would clutter and overcomplicate this one. As a result, I'm closing this issue here.