diff --git a/src/vs/workbench/contrib/debug/browser/debugSession.ts b/src/vs/workbench/contrib/debug/browser/debugSession.ts index d3dccdf475c..058ab97e711 100644 --- a/src/vs/workbench/contrib/debug/browser/debugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/debugSession.ts @@ -908,13 +908,19 @@ export class DebugSession implements IDebugSession { this.model.clearThreads(this.getId(), false, threadId); this._onDidChangeState.fire(); // If the focused thread does get stopped in the next 800ms auto focus another thread or session https://github.com/microsoft/vscode/issues/125144 - setTimeout(() => { - if (typeof threadId === 'number' && this.debugService.getViewModel().focusedThread?.threadId === threadId && this.debugService.state !== State.Stopped) { + if (typeof threadId === 'number') { + const thread = this.debugService.getViewModel().focusedThread; + if (thread && thread.threadId === threadId && !thread.stopped) { const toFocusThreadId = this.getStoppedDetails()?.threadId; const toFocusThread = typeof toFocusThreadId === 'number' ? this.getThread(toFocusThreadId) : undefined; this.debugService.focusStackFrame(undefined, toFocusThread); } - }, 800); + } else { + const session = this.debugService.getViewModel().focusedSession; + if (session && session.getId() === this.getId() && session.state !== State.Stopped) { + this.debugService.focusStackFrame(undefined); + } + } })); const outputQueue = new Queue();