From 1d3fdaf8b2e508c508a193061c1c61d8652eefd4 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 14 Oct 2020 16:51:29 +0200 Subject: [PATCH] Go to Reference does not unfold folded regions under some circumstances. Fixes #93393. Fixes #59383. Fixes #41419 --- src/vs/editor/contrib/folding/folding.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/folding/folding.ts b/src/vs/editor/contrib/folding/folding.ts index 2372e88992262..251f7aa160756 100644 --- a/src/vs/editor/contrib/folding/folding.ts +++ b/src/vs/editor/contrib/folding/folding.ts @@ -63,6 +63,7 @@ export class FoldingController extends Disposable implements IEditorContribution private _isEnabled: boolean; private _useFoldingProviders: boolean; private _unfoldOnClickAfterEndOfLine: boolean; + private _restoringViewState: boolean; private readonly foldingDecorationProvider: FoldingDecorationProvider; @@ -93,6 +94,7 @@ export class FoldingController extends Disposable implements IEditorContribution this._isEnabled = options.get(EditorOption.folding); this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation'; this._unfoldOnClickAfterEndOfLine = options.get(EditorOption.unfoldOnClickAfterEndOfLine); + this._restoringViewState = false; this.foldingModel = null; this.hiddenRangeModel = null; @@ -175,7 +177,12 @@ export class FoldingController extends Disposable implements IEditorContribution if (foldingModel) { foldingModel.then(foldingModel => { if (foldingModel) { - foldingModel.applyMemento(collapsedRegions); + this._restoringViewState = true; + try { + foldingModel.applyMemento(collapsedRegions); + } finally { + this._restoringViewState = false; + } } }).then(undefined, onUnexpectedError); } @@ -297,7 +304,7 @@ export class FoldingController extends Disposable implements IEditorContribution } private onHiddenRangesChanges(hiddenRanges: IRange[]) { - if (this.hiddenRangeModel && hiddenRanges.length) { + if (this.hiddenRangeModel && hiddenRanges.length && !this._restoringViewState) { let selections = this.editor.getSelections(); if (selections) { if (this.hiddenRangeModel.adjustSelections(selections)) {