Skip to content

Commit 58f630e

Browse files
authored
Merge pull request microsoft#57716 from Microsoft/aweinand/customRequest
support early customRequest
2 parents 3057d6f + 812fe77 commit 58f630e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
88
import uri from 'vs/base/common/uri';
9-
import { IDebugService, IConfig, IDebugConfigurationProvider, IBreakpoint, IFunctionBreakpoint, IBreakpointData, IAdapterExecutable, ITerminalSettings, IDebugAdapter, IDebugAdapterProvider } from 'vs/workbench/parts/debug/common/debug';
9+
import { IDebugService, IConfig, IDebugConfigurationProvider, IBreakpoint, IFunctionBreakpoint, IBreakpointData, IAdapterExecutable, ITerminalSettings, IDebugAdapter, IDebugAdapterProvider, ISession } from 'vs/workbench/parts/debug/common/debug';
1010
import { TPromise } from 'vs/base/common/winjs.base';
1111
import {
1212
ExtHostContext, ExtHostDebugServiceShape, MainThreadDebugServiceShape, DebugSessionUUID, MainContext,
@@ -28,6 +28,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
2828
private _breakpointEventsActive: boolean;
2929
private _debugAdapters: Map<number, ExtensionHostDebugAdapter>;
3030
private _debugAdaptersHandleCounter = 1;
31+
private _sessions: Map<DebugSessionUUID, ISession>;
3132

3233
constructor(
3334
extHostContext: IExtHostContext,
@@ -38,15 +39,20 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
3839
this._toDispose.push(debugService.onDidNewSession(session => {
3940
this._proxy.$acceptDebugSessionStarted(<DebugSessionUUID>session.getId(), session.configuration.type, session.getName(false));
4041
}));
42+
this._sessions = new Map();
4143
this._toDispose.push(debugService.onWillNewSession(session => {
44+
this._sessions.set(session.getId(), session);
4245
// Need to start listening early to new session events because a custom event can come while a session is initialising
4346
this._toDispose.push(session.onDidCustomEvent(event => {
4447
if (event && event.sessionId) {
4548
this._proxy.$acceptDebugSessionCustomEvent(event.sessionId, session.configuration.type, session.configuration.name, event);
4649
}
4750
}));
4851
}));
49-
this._toDispose.push(debugService.onDidEndSession(proc => this._proxy.$acceptDebugSessionTerminated(<DebugSessionUUID>proc.getId(), proc.configuration.type, proc.getName(false))));
52+
this._toDispose.push(debugService.onDidEndSession(session => {
53+
this._proxy.$acceptDebugSessionTerminated(<DebugSessionUUID>session.getId(), session.configuration.type, session.getName(false));
54+
this._sessions.delete(<DebugSessionUUID>session.getId());
55+
}));
5056
this._toDispose.push(debugService.getViewModel().onDidFocusSession(proc => {
5157
if (proc) {
5258
this._proxy.$acceptDebugSessionActiveChanged(<DebugSessionUUID>proc.getId(), proc.configuration.type, proc.getName(false));
@@ -220,9 +226,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
220226
}
221227

222228
public $customDebugAdapterRequest(sessionId: DebugSessionUUID, request: string, args: any): TPromise<any> {
223-
const process = this.debugService.getModel().getSessions().filter(p => p.getId() === sessionId).pop();
224-
if (process) {
225-
return process.raw.custom(request, args).then(response => {
229+
const session = this._sessions.get(sessionId);
230+
if (session) {
231+
return session.raw.custom(request, args).then(response => {
226232
if (response && response.success) {
227233
return response.body;
228234
} else {

0 commit comments

Comments
 (0)