提交 32262c4b 编写于 作者: M Martin Aeschlimann

Slow to switch to/from tab with large collapsed section. Fixes #32330

上级 5d299626
......@@ -123,14 +123,33 @@ export class FoldingController implements IFoldingController {
if (!state || !Array.isArray(state.collapsedRegions) || state.collapsedRegions.length === 0 || state.lineCount !== model.getLineCount()) {
return;
}
let newFolded = <IFoldingRange[]>state.collapsedRegions;
// State should be applied on the clean state
// Clean the state
this.cleanState();
// apply state
this.applyRegions(<IFoldingRange[]>state.collapsedRegions);
// Start listening to the model
this.onModelChanged();
if (this.decorations.length > 0) {
let hasChanges = false;
let i = 0;
this.editor.changeDecorations(changeAccessor => {
this.decorations.forEach(d => {
if (i === newFolded.length || d.startLineNumber < newFolded[i].startLineNumber) {
if (d.isCollapsed) {
d.setCollapsed(false, changeAccessor);
hasChanges = true;
}
} else if (d.startLineNumber === newFolded[i].startLineNumber) {
if (!d.isCollapsed) {
d.setCollapsed(true, changeAccessor);
hasChanges = true;
}
i++;
} else {
return; // folding regions doesn't match, don't try to restore
}
});
});
if (hasChanges) {
this.updateHiddenAreas(void 0);
}
}
}
private cleanState(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册