src/vs/editor/contrib/folding/browser/foldingModel.ts/FoldingModel/update
class FoldingModel:	public update(newRegions: FoldingRegions, blockedLineNumers: number[] = []): void {
		const newEditorDecorations: IModelDeltaDecoration[] = [];

		const isBlocked = (startLineNumber: number, endLineNumber: number) => {
			for (const blockedLineNumber of blockedLineNumers) {
				if (startLineNumber < blockedLineNumber && blockedLineNumber <= endLineNumber) { // first line is visible
					return true;
				}
			}
			return false;
		};

		let lastHiddenLine = -1;

		const initRange = (index: number, isCollapsed: boolean) => {
			const startLineNumber = newRegions.getStartLineNumber(index);
			const endLineNumber = newRegions.getEndLineNumber(index);
			if (!isCollapsed) {
				isCollapsed = newRegions.isCollapsed(index);
			}
			if (isCollapsed && isBlocked(startLineNumber, endLineNumber)) {
				isCollapsed = false;
			}
			newRegions.setCollapsed(index, isCollapsed);

			const maxColumn = this._textModel.getLineMaxColumn(startLineNumber);
			const decorationRange = {
				startLineNumber: startLineNumber,
				startColumn: Math.max(maxColumn - 1, 1), // make it length == 1 to detect deletions
				endLineNumber: startLineNumber,
				endColumn: maxColumn
			};
			newEditorDecorations.push({ range: decorationRange, options: this._decorationProvider.getDecorationOption(isCollapsed, endLineNumber <= lastHiddenLine) });
			if (isCollapsed && endLineNumber > lastHiddenLine) {
				lastHiddenLine = endLineNumber;
			}
		};
		let i = 0;
		const nextCollapsed = () => {
			while (i < this._regions.length) {
				const isCollapsed = this._regions.isCollapsed(i);
				i++;
				if (isCollapsed) {
					return i - 1;
				}
			}
			return -1;
		};

		let k = 0;
		let collapsedIndex = nextCollapsed();
		while (collapsedIndex !== -1 && k < newRegions.length) {
			// get the latest range
			const decRange = this._textModel.getDecorationRange(this._editorDecorationIds[collapsedIndex]);
			if (decRange) {
				const collapsedStartLineNumber = decRange.startLineNumber;
				if (decRange.startColumn === Math.max(decRange.endColumn - 1, 1) && this._textModel.getLineMaxColumn(collapsedStartLineNumber) === decRange.endColumn) { // test that the decoration is still covering the full line else it got deleted
					while (k < newRegions.length) {
						const startLineNumber = newRegions.getStartLineNumber(k);
						if (collapsedStartLineNumber >= startLineNumber) {
							initRange(k, collapsedStartLineNumber === startLineNumber);
							k++;
						} else {
							break;
						}
					}
				}
			}
			collapsedIndex = nextCollapsed();
		}
		while (k < newRegions.length) {
			initRange(k, false);
			k++;
		}

		this._decorationProvider.changeDecorations((changeAccessor) => {
			this._editorDecorationIds = changeAccessor.deltaDecorations(this._editorDecorationIds, newEditorDecorations);
		});
		this._regions = newRegions;
		this._isInitialized = true;
		this._updateEventEmitter.fire({ model: this });
	}