src/vs/editor/contrib/folding/foldingModel.ts/toggleCollapseState
export function toggleCollapseState(foldingModel: FoldingModel, levels: number, lineNumbers: number[]) {
	let toToggle: FoldingRegion[] = [];
	for (let lineNumber of lineNumbers) {
		let region = foldingModel.getRegionAtLine(lineNumber);
		if (region) {
			const doCollapse = !region.isCollapsed;
			toToggle.push(region);
			if (levels > 1) {
				let regionsInside = foldingModel.getRegionsInside(region, (r, level: number) => r.isCollapsed !== doCollapse && level < levels);
				toToggle.push(...regionsInside);
			}
		}
	}
	foldingModel.toggleCollapseState(toToggle);
}