Skip to content

Commit 2e936ef

Browse files
Adopt lifecycle managed by parent (#21467)
closed: #20376
1 parent acd1299 commit 2e936ef

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/client/common/application/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
DebugConsole,
1717
DebugSession,
1818
DebugSessionCustomEvent,
19+
DebugSessionOptions,
1920
DecorationRenderOptions,
2021
Disposable,
2122
DocumentSelector,
@@ -975,7 +976,7 @@ export interface IDebugService {
975976
startDebugging(
976977
folder: WorkspaceFolder | undefined,
977978
nameOrConfiguration: string | DebugConfiguration,
978-
parentSession?: DebugSession,
979+
parentSession?: DebugSession | DebugSessionOptions,
979980
): Thenable<boolean>;
980981

981982
/**

src/client/debugger/extension/hooks/childProcessAttachService.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { inject, injectable } from 'inversify';
77
import { IDebugService } from '../../../common/application/types';
8-
import { DebugConfiguration, DebugSession, l10n, WorkspaceFolder } from 'vscode';
8+
import { DebugConfiguration, DebugSession, l10n, WorkspaceFolder, DebugSessionOptions } from 'vscode';
99
import { noop } from '../../../common/utils/misc';
1010
import { captureTelemetry } from '../../../telemetry';
1111
import { EventName } from '../../../telemetry/constants';
@@ -28,11 +28,17 @@ export class ChildProcessAttachService implements IChildProcessAttachService {
2828
@captureTelemetry(EventName.DEBUGGER_ATTACH_TO_CHILD_PROCESS)
2929
public async attach(data: AttachRequestArguments & DebugConfiguration, parentSession: DebugSession): Promise<void> {
3030
const debugConfig: AttachRequestArguments & DebugConfiguration = data;
31-
const processId = debugConfig.subProcessId!;
3231
const folder = this.getRelatedWorkspaceFolder(debugConfig);
33-
const launched = await this.debugService.startDebugging(folder, debugConfig, parentSession);
32+
const debugSessionOption: DebugSessionOptions = {
33+
parentSession: parentSession,
34+
lifecycleManagedByParent: true,
35+
};
36+
const launched = await this.debugService.startDebugging(folder, debugConfig, debugSessionOption);
3437
if (!launched) {
35-
showErrorMessage(l10n.t('Failed to launch debugger for child process {0}', processId)).then(noop, noop);
38+
showErrorMessage(l10n.t('Failed to launch debugger for child process {0}', debugConfig.subProcessId!)).then(
39+
noop,
40+
noop,
41+
);
3642
}
3743
}
3844

src/test/debugger/extension/hooks/childProcessAttachService.unit.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ suite('Debug - Attach to Child Process', () => {
117117
verify(debugService.startDebugging(undefined, anything(), anything())).once();
118118
sinon.assert.notCalled(showErrorMessageStub);
119119
});
120-
test('Validate debug config is passed as is', async () => {
120+
test('Validate debug config is passed with the correct params', async () => {
121121
const data: LaunchRequestArguments | AttachRequestArguments = {
122122
request: 'attach',
123123
type: 'python',
@@ -140,7 +140,7 @@ suite('Debug - Attach to Child Process', () => {
140140
verify(debugService.startDebugging(undefined, anything(), anything())).once();
141141
const [, secondArg, thirdArg] = capture(debugService.startDebugging).last();
142142
expect(secondArg).to.deep.equal(debugConfig);
143-
expect(thirdArg).to.deep.equal(session);
143+
expect(thirdArg).to.deep.equal({ parentSession: session, lifecycleManagedByParent: true });
144144
sinon.assert.notCalled(showErrorMessageStub);
145145
});
146146
test('Pass data as is if data is attach debug configuration', async () => {
@@ -161,7 +161,7 @@ suite('Debug - Attach to Child Process', () => {
161161
verify(debugService.startDebugging(undefined, anything(), anything())).once();
162162
const [, secondArg, thirdArg] = capture(debugService.startDebugging).last();
163163
expect(secondArg).to.deep.equal(debugConfig);
164-
expect(thirdArg).to.deep.equal(session);
164+
expect(thirdArg).to.deep.equal({ parentSession: session, lifecycleManagedByParent: true });
165165
sinon.assert.notCalled(showErrorMessageStub);
166166
});
167167
test('Validate debug config when parent/root parent was attached', async () => {
@@ -189,7 +189,7 @@ suite('Debug - Attach to Child Process', () => {
189189
verify(debugService.startDebugging(undefined, anything(), anything())).once();
190190
const [, secondArg, thirdArg] = capture(debugService.startDebugging).last();
191191
expect(secondArg).to.deep.equal(debugConfig);
192-
expect(thirdArg).to.deep.equal(session);
192+
expect(thirdArg).to.deep.equal({ parentSession: session, lifecycleManagedByParent: true });
193193
sinon.assert.notCalled(showErrorMessageStub);
194194
});
195195
});

0 commit comments

Comments
 (0)