Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix max call stack error when closing large outline #235893

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/vs/editor/contrib/documentSymbols/browser/outlineModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,20 @@ export class OutlineModel extends TreeElement {
const id = TreeElement.findId(info, container);
const res = new OutlineElement(id, container, info);
if (info.children) {
const stack: { info: DocumentSymbol, container: OutlineElement }[] = [];
for (const childInfo of info.children) {
OutlineModel._makeOutlineElement(childInfo, res);
stack.push({ info: childInfo, container: res });
}
while (stack.length > 0) {
const { info, container } = stack.pop()!;
const id = TreeElement.findId(info, container);
const res = new OutlineElement(id, container, info);
container.children.set(res.id, res);
if (info.children) {
for (const childInfo of info.children) {
stack.push({ info: childInfo, container: res });
}
}
}
}
container.children.set(res.id, res);
Expand Down Expand Up @@ -368,7 +380,12 @@ export class OutlineModel extends TreeElement {
}

private static _flattenDocumentSymbols(bucket: DocumentSymbol[], entries: DocumentSymbol[], overrideContainerLabel: string): void {
const stack: { entry: DocumentSymbol, overrideContainerLabel: string }[] = [];
for (const entry of entries) {
stack.push({ entry, overrideContainerLabel });
}
while (stack.length > 0) {
const { entry, overrideContainerLabel } = stack.pop()!;
bucket.push({
kind: entry.kind,
tags: entry.tags,
Expand All @@ -379,10 +396,10 @@ export class OutlineModel extends TreeElement {
selectionRange: entry.selectionRange,
children: undefined, // we flatten it...
});

// Recurse over children
if (entry.children) {
OutlineModel._flattenDocumentSymbols(bucket, entry.children, entry.name);
for (const child of entry.children) {
stack.push({ entry: child, overrideContainerLabel: entry.name });
}
}
}
}
Expand Down