src/vs/editor/contrib/folding/foldingModel.ts/filter
export function setCollapseStateForRest(foldingModel: FoldingModel, doCollapse: boolean, blockedLineNumbers: number[]): void {
	let filteredRegions: FoldingRegion[] = [];
	for (let lineNumber of blockedLineNumbers) {
		filteredRegions.push(foldingModel.getAllRegionsAtLine(lineNumber, undefined)[0]);
	}
	let filter = (region: FoldingRegion) => filteredRegions.every((filteredRegion) => !filteredRegion.containedBy(region) && !region.containedBy(filteredRegion)) && region.isCollapsed !== doCollapse;
	let toToggle = foldingModel.getRegionsInside(null, filter);
	foldingModel.toggleCollapseState(toToggle);
}