maptz.vscode.extensions.customfolding icon indicating copy to clipboard operation
maptz.vscode.extensions.customfolding copied to clipboard

Feature Request: only 1 region expanded at a time

Open Die4Ever opened this issue 2 years ago • 7 comments

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

Die4Ever avatar Jul 18 '21 02:07 Die4Ever

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.

maptz avatar Aug 02 '21 22:08 maptz

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

Die4Ever avatar Aug 02 '21 22:08 Die4Ever

Have you tried just collapsing all regions when in a region block? That effectively opens only the current region.

maptz avatar Aug 02 '21 23:08 maptz

yea that's cool but it isn't automatic, it's more button clicks on my part

Die4Ever avatar Aug 02 '21 23:08 Die4Ever

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.

maptz avatar Aug 02 '21 23:08 maptz

I've never looked at the APIs for VSC extensions, but is there not an event called when a region is expanded?

Die4Ever avatar Aug 02 '21 23:08 Die4Ever

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.

maptz avatar Aug 03 '21 00:08 maptz

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.

maptz avatar Jan 17 '23 23:01 maptz