(e: vscode.DebugSessionCustomEvent, evType: ChainedEvents)
| 533 | } |
| 534 | |
| 535 | private async startChainedConfigs(e: vscode.DebugSessionCustomEvent, evType: ChainedEvents) { |
| 536 | const adapterArgs = e?.body?.info as ConfigurationArguments; |
| 537 | const cDbgParent = CDebugSession.GetSession(e.session, adapterArgs); |
| 538 | if (!adapterArgs || !adapterArgs.chainedConfigurations?.enabled) { return; } |
| 539 | const unique = adapterArgs.chainedConfigurations.launches.filter((x, ix) => { |
| 540 | return ix === adapterArgs.chainedConfigurations.launches.findIndex((v, ix) => v.name === x.name); |
| 541 | }); |
| 542 | const filtered = unique.filter((launch) => { |
| 543 | return (launch.enabled && (launch.waitOnEvent === evType) && launch.name); |
| 544 | }); |
| 545 | |
| 546 | let delay = 0; |
| 547 | let count = filtered.length; |
| 548 | for (const launch of filtered) { |
| 549 | count--; |
| 550 | const childOptions: vscode.DebugSessionOptions = { |
| 551 | consoleMode : vscode.DebugConsoleMode.Separate, |
| 552 | noDebug : adapterArgs.noDebug, |
| 553 | compact : false |
| 554 | }; |
| 555 | if (launch.lifecycleManagedByParent) { |
| 556 | // VSCode 'lifecycleManagedByParent' does not work as documented. The fact that there |
| 557 | // is a parent means it is managed and 'lifecycleManagedByParent' if ignored. |
| 558 | childOptions.lifecycleManagedByParent = true; |
| 559 | childOptions.parentSession = e.session; |
| 560 | } |
| 561 | delay += Math.max(launch.delayMs || 0, 0); |
| 562 | const child = new CDebugChainedSessionItem(cDbgParent, launch, childOptions); |
| 563 | const folder = this.getWsFolder(launch.folder, e.session.workspaceFolder, launch.name); |
| 564 | setTimeout(() => { |
| 565 | vscode.debug.startDebugging(folder, launch.name, childOptions).then((success) => { |
| 566 | if (!success) { |
| 567 | vscode.window.showErrorMessage('Failed to launch chained configuration ' + launch.name); |
| 568 | } |
| 569 | CDebugChainedSessionItem.RemoveItem(child); |
| 570 | }, (e) => { |
| 571 | vscode.window.showErrorMessage(`Failed to launch chained configuration ${launch.name}: ${e}`); |
| 572 | CDebugChainedSessionItem.RemoveItem(child); |
| 573 | }); |
| 574 | }, delay); |
| 575 | if (launch && launch.detached && (count > 0)) { |
| 576 | try { |
| 577 | // tslint:disable-next-line: one-variable-per-declaration |
| 578 | let res: (value: vscode.DebugSessionCustomEvent) => void; |
| 579 | let rej: (reason?: any) => void; |
| 580 | const prevStartedPromise = new Promise<vscode.DebugSessionCustomEvent>((resolve, reject) => { |
| 581 | res = resolve; |
| 582 | rej = reject; |
| 583 | }); |
| 584 | this.serverStartedEvent = new ServerStartedPromise(launch.name, prevStartedPromise, res, rej); |
| 585 | let to = setTimeout(() => { |
| 586 | if (this.serverStartedEvent) { |
| 587 | this.serverStartedEvent.reject(new Error(`Timeout starting chained session: ${launch.name}`)); |
| 588 | this.serverStartedEvent = undefined; |
| 589 | } |
| 590 | to = undefined; |
| 591 | }, 5000); |
| 592 | await prevStartedPromise; |
no test coverage detected