diff --git a/src/vs/workbench/api/browser/mainThreadDebugService.ts b/src/vs/workbench/api/browser/mainThreadDebugService.ts index 3b727aa3f6f..082c1f4114f 100644 --- a/src/vs/workbench/api/browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/browser/mainThreadDebugService.ts @@ -227,7 +227,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb private getSession(sessionId: DebugSessionUUID | undefined): IDebugSession | undefined { if (sessionId) { - return this.debugService.getModel().getSessions(true).filter(s => s.getId() === sessionId).pop(); + return this.debugService.getModel().getSession(sessionId, true); } return undefined; } @@ -243,7 +243,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb } public $customDebugAdapterRequest(sessionId: DebugSessionUUID, request: string, args: any): Promise { - const session = this.debugService.getModel().getSessions(true).filter(s => s.getId() === sessionId).pop(); + const session = this.debugService.getModel().getSession(sessionId, true); if (session) { return session.customRequest(request, args).then(response => { if (response && response.success) { diff --git a/src/vs/workbench/contrib/debug/browser/callStackView.ts b/src/vs/workbench/contrib/debug/browser/callStackView.ts index bdc577ae4c0..2071899ed9f 100644 --- a/src/vs/workbench/contrib/debug/browser/callStackView.ts +++ b/src/vs/workbench/contrib/debug/browser/callStackView.ts @@ -170,7 +170,7 @@ export class CallStackView extends ViewletPanel { focusStackFrame(undefined, undefined, element); } if (element instanceof ThreadAndSessionIds) { - const session = this.debugService.getModel().getSessions().filter(p => p.getId() === element.sessionId).pop(); + const session = this.debugService.getModel().getSession(element.sessionId); const thread = session && session.getThread(element.threadId); if (thread) { (thread).fetchCallStack() diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index 4043838c205..30b3ef44795 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -389,6 +389,7 @@ export interface IEvaluate { } export interface IDebugModel extends ITreeElement { + getSession(sessionId: string | undefined, includeInactive?: boolean): IDebugSession | undefined; getSessions(includeInactive?: boolean): IDebugSession[]; getBreakpoints(filter?: { uri?: uri, lineNumber?: number, column?: number, enabledOnly?: boolean }): ReadonlyArray; areBreakpointsActivated(): boolean; diff --git a/src/vs/workbench/contrib/debug/common/debugContentProvider.ts b/src/vs/workbench/contrib/debug/common/debugContentProvider.ts index 37859760d0e..0b01b0c03bc 100644 --- a/src/vs/workbench/contrib/debug/common/debugContentProvider.ts +++ b/src/vs/workbench/contrib/debug/common/debugContentProvider.ts @@ -81,7 +81,7 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC if (resource.query) { const data = Source.getEncodedDebugData(resource); - session = this.debugService.getModel().getSessions().filter(p => p.getId() === data.sessionId).pop(); + session = this.debugService.getModel().getSession(data.sessionId); } if (!session) { diff --git a/src/vs/workbench/contrib/debug/common/debugModel.ts b/src/vs/workbench/contrib/debug/common/debugModel.ts index 934672a612f..240cffee3c8 100644 --- a/src/vs/workbench/contrib/debug/common/debugModel.ts +++ b/src/vs/workbench/contrib/debug/common/debugModel.ts @@ -778,6 +778,13 @@ export class DebugModel implements IDebugModel { return 'root'; } + getSession(sessionId: string | undefined, includeInactive = false): IDebugSession | undefined { + if (sessionId) { + return this.getSessions(includeInactive).filter(s => s.getId() === sessionId).pop(); + } + return undefined; + } + getSessions(includeInactive = false): IDebugSession[] { // By default do not return inactive sesions. // However we are still holding onto inactive sessions due to repl and debug service session revival (eh scenario) diff --git a/src/vs/workbench/contrib/debug/electron-browser/debugService.ts b/src/vs/workbench/contrib/debug/electron-browser/debugService.ts index f776d4142a9..8c0d6605cf2 100644 --- a/src/vs/workbench/contrib/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/electron-browser/debugService.ts @@ -137,7 +137,7 @@ export class DebugService implements IDebugService { this.lifecycleService.onShutdown(this.dispose, this); this.toDispose.push(this.broadcastService.onBroadcast(broadcast => { - const session = this.model.getSessions(true).filter(s => s.getId() === broadcast.payload.debugId).pop(); + const session = this.model.getSession(broadcast.payload.debugId, true); if (session) { switch (broadcast.channel) {