diff --git a/src/extension.ts b/src/extension.ts index 35c6671d1..2f29114df 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -536,7 +536,16 @@ export class Extension implements RunHooks { if (mode === 'debug') { const debugEnd = new this._vscode.CancellationTokenSource(); testRun.token.onCancellationRequested(() => debugEnd.cancel()); - this._vscode.debug.onDidTerminateDebugSession(() => debugEnd.cancel()); + + let mainDebugRun: vscodeTypes.DebugSession | undefined; + this._vscode.debug.onDidStartDebugSession(session => { mainDebugRun ??= session; }); + this._vscode.debug.onDidTerminateDebugSession(session => { + // child processes have their own debug sessions, + // but we only want to stop debugging if the user cancels the main session + if (session.id === mainDebugRun?.id) + debugEnd.cancel(); + }); + await model.debugTests(items, testListener, debugEnd.token); } else { // Force trace viewer update to surface check version errors.