src/vs/editor/contrib/folding/browser/folding.ts/FoldingController/restoreViewState
class FoldingController:	public restoreViewState(state: FoldingStateMemento): void {
		const model = this.editor.getModel();
		if (!model || !this._isEnabled || model.isTooLargeForTokenization() || !this.hiddenRangeModel) {
			return;
		}
		if (!state || state.lineCount !== model.getLineCount()) {
			return;
		}

		this._currentModelHasFoldedImports = !!state.foldedImports;
		if (!state.collapsedRegions) {
			return;
		}

		if (state.provider === ID_SYNTAX_PROVIDER || state.provider === ID_INIT_PROVIDER) {
			this.foldingStateMemento = state;
		}

		const collapsedRegions = state.collapsedRegions;
		// set the hidden ranges right away, before waiting for the folding model.
		if (this.hiddenRangeModel.applyMemento(collapsedRegions)) {
			const foldingModel = this.getFoldingModel();
			if (foldingModel) {
				foldingModel.then(foldingModel => {
					if (foldingModel) {
						this._restoringViewState = true;
						try {
							foldingModel.applyMemento(collapsedRegions);
						} finally {
							this._restoringViewState = false;
						}
					}
				}).then(undefined, onUnexpectedError);
			}
		}
	}