6
6
7
7
import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
8
8
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' ;
10
10
import { TPromise } from 'vs/base/common/winjs.base' ;
11
11
import {
12
12
ExtHostContext , ExtHostDebugServiceShape , MainThreadDebugServiceShape , DebugSessionUUID , MainContext ,
@@ -28,6 +28,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
28
28
private _breakpointEventsActive : boolean ;
29
29
private _debugAdapters : Map < number , ExtensionHostDebugAdapter > ;
30
30
private _debugAdaptersHandleCounter = 1 ;
31
+ private _sessions : Map < DebugSessionUUID , ISession > ;
31
32
32
33
constructor (
33
34
extHostContext : IExtHostContext ,
@@ -38,15 +39,20 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
38
39
this . _toDispose . push ( debugService . onDidNewSession ( session => {
39
40
this . _proxy . $acceptDebugSessionStarted ( < DebugSessionUUID > session . getId ( ) , session . configuration . type , session . getName ( false ) ) ;
40
41
} ) ) ;
42
+ this . _sessions = new Map ( ) ;
41
43
this . _toDispose . push ( debugService . onWillNewSession ( session => {
44
+ this . _sessions . set ( session . getId ( ) , session ) ;
42
45
// Need to start listening early to new session events because a custom event can come while a session is initialising
43
46
this . _toDispose . push ( session . onDidCustomEvent ( event => {
44
47
if ( event && event . sessionId ) {
45
48
this . _proxy . $acceptDebugSessionCustomEvent ( event . sessionId , session . configuration . type , session . configuration . name , event ) ;
46
49
}
47
50
} ) ) ;
48
51
} ) ) ;
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
+ } ) ) ;
50
56
this . _toDispose . push ( debugService . getViewModel ( ) . onDidFocusSession ( proc => {
51
57
if ( proc ) {
52
58
this . _proxy . $acceptDebugSessionActiveChanged ( < DebugSessionUUID > proc . getId ( ) , proc . configuration . type , proc . getName ( false ) ) ;
@@ -220,9 +226,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
220
226
}
221
227
222
228
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 => {
226
232
if ( response && response . success ) {
227
233
return response . body ;
228
234
} else {
0 commit comments