Skip to content

Commit 96eb4cf

Browse files
committed
proposed API: add parentSession to startDebugging; fixes microsoft#70219
1 parent 7d20b64 commit 96eb4cf

8 files changed

Lines changed: 33 additions & 10 deletions

File tree

extensions/debug-server-ready/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class ServerReadyDetector extends vscode.Disposable {
119119
request: 'launch',
120120
url: uri,
121121
webRoot: args.webRoot || WEB_ROOT
122-
});
122+
}, session);
123123
break;
124124
default:
125125
// not supported

src/vs/vscode.proposed.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,22 @@ declare module 'vscode' {
596596

597597
//#region André: debug
598598

599+
export namespace debug {
600+
601+
/**
602+
* Start debugging by using either a named launch or named compound configuration,
603+
* or by directly passing a [DebugConfiguration](#DebugConfiguration).
604+
* The named configurations are looked up in '.vscode/launch.json' found in the given folder.
605+
* Before debugging starts, all unsaved files are saved and the launch configurations are brought up-to-date.
606+
* Folder specific variables used in the configuration (e.g. '${workspaceFolder}') are resolved against the given folder.
607+
* @param folder The [workspace folder](#WorkspaceFolder) for looking up named configurations and resolving variables or `undefined` for a non-folder setup.
608+
* @param nameOrConfiguration Either the name of a debug or compound configuration or a [DebugConfiguration](#DebugConfiguration) object.
609+
* @param parent If specified the newly created debug session is registered as a "child" session of a "parent" debug session.
610+
* @return A thenable that resolves when debugging could be successfully started.
611+
*/
612+
export function startDebugging(folder: WorkspaceFolder | undefined, nameOrConfiguration: string | DebugConfiguration, parentSession?: DebugSession): Thenable<boolean>;
613+
}
614+
599615
// deprecated
600616

601617
export interface DebugConfigurationProvider {

src/vs/workbench/api/electron-browser/mainThreadDebugService.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,17 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
226226
}
227227
}
228228

229-
public $startDebugging(_folderUri: uri | undefined, nameOrConfiguration: string | IConfig): Promise<boolean> {
229+
private getSession(sessionId: DebugSessionUUID | undefined): IDebugSession | undefined {
230+
if (sessionId) {
231+
return this.debugService.getModel().getSessions(true).filter(s => s.getId() === sessionId).pop();
232+
}
233+
return undefined;
234+
}
235+
236+
public $startDebugging(_folderUri: uri | undefined, nameOrConfiguration: string | IConfig, parentSessionID: DebugSessionUUID | undefined): Promise<boolean> {
230237
const folderUri = _folderUri ? uri.revive(_folderUri) : undefined;
231238
const launch = this.debugService.getConfigurationManager().getLaunch(folderUri);
232-
return this.debugService.startDebugging(launch, nameOrConfiguration).then(success => {
239+
return this.debugService.startDebugging(launch, nameOrConfiguration, false, this.getSession(parentSessionID)).then(success => {
233240
return success;
234241
}, err => {
235242
return Promise.reject(new Error(err && err.message ? err.message : 'cannot start debugging'));

src/vs/workbench/api/node/extHost.api.impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ export function createApiFactory(
695695
registerDebugAdapterTrackerFactory(debugType: string, factory: vscode.DebugAdapterTrackerFactory) {
696696
return extHostDebugService.registerDebugAdapterTrackerFactory(debugType, factory);
697697
},
698-
startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration) {
699-
return extHostDebugService.startDebugging(folder, nameOrConfig);
698+
startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration, parentSession?: vscode.DebugSession) {
699+
return extHostDebugService.startDebugging(folder, nameOrConfig, parentSession);
700700
},
701701
addBreakpoints(breakpoints: vscode.Breakpoint[]) {
702702
return extHostDebugService.addBreakpoints(breakpoints);

src/vs/workbench/api/node/extHost.protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ export interface MainThreadDebugServiceShape extends IDisposable {
646646
$unregisterDebugConfigurationProvider(handle: number): void;
647647
$unregisterDebugAdapterDescriptorFactory(handle: number): void;
648648
$unregisterDebugAdapterTrackerFactory(handle: number): void;
649-
$startDebugging(folder: UriComponents | undefined, nameOrConfig: string | vscode.DebugConfiguration): Promise<boolean>;
649+
$startDebugging(folder: UriComponents | undefined, nameOrConfig: string | vscode.DebugConfiguration, parentSessionID: string | undefined): Promise<boolean>;
650650
$customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): Promise<any>;
651651
$appendDebugConsole(value: string): void;
652652
$startBreakpointEvents(): void;

src/vs/workbench/api/node/extHostDebugService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
241241
return this._debugServiceProxy.$unregisterBreakpoints(ids, fids);
242242
}
243243

244-
public startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration): Promise<boolean> {
245-
return this._debugServiceProxy.$startDebugging(folder ? folder.uri : undefined, nameOrConfig);
244+
public startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration, parentSession?: vscode.DebugSession): Promise<boolean> {
245+
return this._debugServiceProxy.$startDebugging(folder ? folder.uri : undefined, nameOrConfig, parentSession ? parentSession.id : undefined);
246246
}
247247

248248
public registerDebugConfigurationProvider(type: string, provider: vscode.DebugConfigurationProvider): vscode.Disposable {

src/vs/workbench/contrib/debug/common/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ export interface IDebugService {
789789
* Returns true if the start debugging was successfull. For compound launches, all configurations have to start successfuly for it to return success.
790790
* On errors the startDebugging will throw an error, however some error and cancelations are handled and in that case will simply return false.
791791
*/
792-
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, noDebug?: boolean): Promise<boolean>;
792+
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, noDebug?: boolean, parentSession?: IDebugSession): Promise<boolean>;
793793

794794
/**
795795
* Restarts a session or creates a new one if there is no active session.

src/vs/workbench/contrib/debug/electron-browser/debugService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class DebugService implements IDebugService {
252252
* main entry point
253253
* properly manages compounds, checks for errors and handles the initializing state.
254254
*/
255-
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, noDebug = false): Promise<boolean> {
255+
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, noDebug = false, parentSession?: IDebugSession): Promise<boolean> {
256256

257257
this.startInitializingState();
258258
// make sure to save all files and that the configuration is up to date

0 commit comments

Comments
 (0)