mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
Debug API for tracking current debug session; fixes #30157
This commit is contained in:
@@ -463,12 +463,19 @@ export function createApiFactory(
|
||||
|
||||
// namespace: debug
|
||||
const debug: typeof vscode.debug = {
|
||||
get activeDebugSession() {
|
||||
assertProposedApi(extension);
|
||||
return extHostDebugService.activeDebugSession;
|
||||
},
|
||||
createDebugSession(config: vscode.DebugConfiguration) {
|
||||
return extHostDebugService.createDebugSession(config);
|
||||
},
|
||||
onDidTerminateDebugSession(listener, thisArg?, disposables?) {
|
||||
return extHostDebugService.onDidTerminateDebugSession(listener, thisArg, disposables);
|
||||
}
|
||||
},
|
||||
onDidChangeActiveDebugSession: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
|
||||
return extHostDebugService.onDidChangeActiveDebugSession(listener, thisArg, disposables);
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -501,6 +501,7 @@ export abstract class ExtHostTaskShape {
|
||||
|
||||
export abstract class ExtHostDebugServiceShape {
|
||||
$acceptDebugSessionTerminated(id: DebugSessionUUID, type: string, name: string): void { throw ni(); }
|
||||
$acceptDebugSessionActiveChanged(id: DebugSessionUUID | undefined, type?: string, name?: string): void { throw ni(); }
|
||||
}
|
||||
|
||||
// --- proxy identifiers
|
||||
|
||||
@@ -21,11 +21,18 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
|
||||
private _onDidTerminateDebugSession: Emitter<vscode.DebugSession>;
|
||||
get onDidTerminateDebugSession(): Event<vscode.DebugSession> { return this._onDidTerminateDebugSession.event; }
|
||||
|
||||
private _onDidChangeActiveDebugSession: Emitter<vscode.DebugSession | undefined>;
|
||||
get onDidChangeActiveDebugSession(): Event<vscode.DebugSession | undefined> { return this._onDidChangeActiveDebugSession.event; }
|
||||
|
||||
private _activeDebugSession: vscode.DebugSession | undefined;
|
||||
get activeDebugSession(): vscode.DebugSession | undefined { return this._activeDebugSession; }
|
||||
|
||||
constructor(threadService: IThreadService) {
|
||||
super();
|
||||
|
||||
this._onDidTerminateDebugSession = new Emitter<vscode.DebugSession>();
|
||||
this._onDidChangeActiveDebugSession = new Emitter<vscode.DebugSession>();
|
||||
|
||||
this._debugServiceProxy = threadService.get(MainContext.MainThreadDebugService);
|
||||
}
|
||||
|
||||
@@ -47,6 +54,19 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
|
||||
this._onDidTerminateDebugSession.fire(debugSession);
|
||||
this._debugSessions.delete(id);
|
||||
}
|
||||
|
||||
public $acceptDebugSessionActiveChanged(id: DebugSessionUUID | undefined, type?: string, name?: string): void {
|
||||
|
||||
if (id) {
|
||||
this._activeDebugSession = this._debugSessions.get(id);
|
||||
if (!this._activeDebugSession) {
|
||||
this._activeDebugSession = new ExtHostDebugSession(this._debugServiceProxy, id, type, name);
|
||||
}
|
||||
} else {
|
||||
this._activeDebugSession = undefined;
|
||||
}
|
||||
this._onDidChangeActiveDebugSession.fire(this._activeDebugSession);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostDebugSession implements vscode.DebugSession {
|
||||
|
||||
Reference in New Issue
Block a user