diff --git a/src/vs/workbench/contrib/debug/browser/debugSession.ts b/src/vs/workbench/contrib/debug/browser/debugSession.ts index 0ca0de841ed..73809e2e712 100644 --- a/src/vs/workbench/contrib/debug/browser/debugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/debugSession.ts @@ -47,6 +47,7 @@ export class DebugSession implements IDebugSession { private sources = new Map(); private threads = new Map(); + private threadIds: number[] = []; private cancellationMap = new Map(); private rawListeners: IDisposable[] = []; private fetchThreadsScheduler: RunOnceScheduler | undefined; @@ -738,7 +739,12 @@ export class DebugSession implements IDebugSession { getAllThreads(): IThread[] { const result: IThread[] = []; - this.threads.forEach(t => result.push(t)); + this.threadIds.forEach((threadId) => { + const thread = this.threads.get(threadId); + if (thread) { + result.push(thread); + } + }); return result; } @@ -763,6 +769,7 @@ export class DebugSession implements IDebugSession { if (removeThreads) { this.threads.clear(); + this.threadIds = []; ExpressionContainer.allValues.clear(); } } @@ -773,9 +780,9 @@ export class DebugSession implements IDebugSession { } rawUpdate(data: IRawModelUpdate): void { - const threadIds: number[] = []; + this.threadIds = []; data.threads.forEach(thread => { - threadIds.push(thread.id); + this.threadIds.push(thread.id); if (!this.threads.has(thread.id)) { // A new thread came in, initialize it. this.threads.set(thread.id, new Thread(this, thread.name, thread.id)); @@ -789,7 +796,7 @@ export class DebugSession implements IDebugSession { }); this.threads.forEach(t => { // Remove all old threads which are no longer part of the update #75980 - if (threadIds.indexOf(t.threadId) === -1) { + if (this.threadIds.indexOf(t.threadId) === -1) { this.threads.delete(t.threadId); } });