Change:
In other IDEs like Rstudio Shift+click on the arrows near the line number folds the fold-able sub parts of that part. ! This is very handy since it only folds everything within the scope of a specific region and can help user to have a better view on the sub-parts.
In VSCode, Shift + Click recursively folds the range and all contained ranges. So for what you want you can press and
your "solution" to address this works and I appreciate the suggestion and also title modification, but I think you also agree that it is very un-intuitive since achieving something should not be through doing something (recursive folding: <kbdSHIFT</kbd+<kbdClick</kbd) first and undoing something else (normal unfolding: <kbdClick</kbd). I would also like to raise a point here: recursive folding is very useless since you are folding the top level as well and you are not seeing the inner ranges to know if they are folded or not. This makes it also confusing since one cannot know if something is previously normally folded or recursively (there is no icon difference but the editor have memorized it internally!). The best solution would be <kbdSHIFT</kbd+<kbdClick</kbd: "fold inner ranges" if the current range is unfolded "open the range with inner ranges folded" if the current range is folded This way the user don't get any surprises when unfolding a range and can control if the inner ranges should be folded or unfolded while unfolding a range.
do you guys of VSCode Team agree with suggestion? Because if you agree, I can try to contribute making a pull request with this change. It looks like a simple change at file where method is invoked.
I would like to point this part out: I think you meant: "open the range with inner ranges unfolded" if the current range is folded. Because RStudio has this second behavior when current range is folded. Anyway, I made these changes on my local VSCode fork and I think it's really nice. This way we have simpler control over inner ranges.
Thanks for putting some effort into this and ultimately . Regarding your last comment, I'm a bit lost. What I was/am after is to force inner ranges ("child nodes" if we think about it as XML-like hierarchy) folded while the user is at the outer range (parent node). The logic/rationale I have is simple: codes tend to be large and typically segmented by inner ranges. The programmer would usually want to navigate through the code and understand it's structure, so it is necessary to start from abstract view (inner ranges folded) and get the general gist of what the current range is doing and then start expanding the inner ranges one by one to explore them if needed. Needless to say that a good code is well commented and has an organized structure. I hope my brief explanation above has clarified my point.
Ok, let's give this a try. I hope this doesn't break other users. We can still add an other modifier key.
I made the following improvement: when doing shift+click and all children are already folded (or there are no children), then the current region is also folded ! That way shift+click always does something and you can loop the states. Let me know what you think.
Good idea!! I liked it.

Discussion:
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { onUnexpectedError } from 'vs/base/common/errors'; import { RawContextKey, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; <ins> import { IMouseEvent } from 'vs/base/browser/mouseEvent'; </ins> const CONTEXT_FOLDING_ENABLED = new RawContextKey<boolean>('foldingEnabled', false);

if (region && region.startLineNumber === lineNumber) { let isCollapsed = region.isCollapsed; if (iconClicked || isCollapsed) { <del> let toToggle = [region]; if (e.event.middleButton || e.event.shiftKey) { </del> <ins> let toToggle = []; let considerRegionsInside = this.shouldConsiderRegionsInside(e.event); if (isCollapsed || (!isCollapsed && !considerRegionsInside)) { toToggle.push(region); } if (considerRegionsInside) { </ins> toToggle.push(...foldingModel.getRegionsInside(region, (r: FoldingRegion) => r.isCollapsed === isCollapsed)); } foldingModel.toggleCollapseState(toToggle);

}).then(undefined, onUnexpectedError); } <ins> private shouldConsiderRegionsInside(event: IMouseEvent): boolean { return event.middleButton || event.shiftKey; } </ins> public reveal(position: IPosition): void { this.editor.revealPositionInCenterIfOutsideViewport(position, ScrollType.Smooth); }