Skip to content

Commit

Permalink
Go to Reference does not unfold folded regions under some circumstanc…
Browse files Browse the repository at this point in the history
…es. Fixes #93393. Fixes #59383. Fixes #41419
  • Loading branch information
aeschli committed Oct 14, 2020
1 parent 9da8106 commit 1d3fdaf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/vs/editor/contrib/folding/folding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 1d3fdaf

Please sign in to comment.