@@ -50,6 +50,7 @@ export class SessionManager implements Middleware {
50
50
private statusBarItem : vscode . StatusBarItem ;
51
51
private languageServerProcess : PowerShellProcess ;
52
52
private debugSessionProcess : PowerShellProcess ;
53
+ private debugEventHandler : vscode . Disposable ;
53
54
private versionDetails : IPowerShellVersionDetails ;
54
55
private registeredCommands : vscode . Disposable [ ] = [ ] ;
55
56
private languageServerClient : LanguageClient = undefined ;
@@ -228,9 +229,10 @@ export class SessionManager implements Middleware {
228
229
this . languageServerClient = undefined ;
229
230
}
230
231
231
- // Kill the PowerShell proceses we spawned
232
+ // Kill the PowerShell process we spawned
232
233
if ( this . debugSessionProcess ) {
233
234
this . debugSessionProcess . dispose ( ) ;
235
+ this . debugEventHandler . dispose ( ) ;
234
236
}
235
237
if ( this . languageServerProcess ) {
236
238
this . languageServerProcess . dispose ( ) ;
@@ -260,6 +262,15 @@ export class SessionManager implements Middleware {
260
262
sessionPath : string ,
261
263
sessionSettings : Settings . ISettings ) : PowerShellProcess {
262
264
265
+ // NOTE: We only support one temporary integrated console at a time. To
266
+ // support more, we need to track each separately, and tie the session
267
+ // for the event handler to the right process (and dispose of the event
268
+ // handler when the process is disposed).
269
+ if ( this . debugSessionProcess ) {
270
+ this . debugSessionProcess . dispose ( )
271
+ this . debugEventHandler . dispose ( ) ;
272
+ }
273
+
263
274
this . debugSessionProcess =
264
275
new PowerShellProcess (
265
276
this . PowerShellExeDetails . exePath ,
@@ -273,10 +284,7 @@ export class SessionManager implements Middleware {
273
284
// Similar to the regular integrated console, we need to send a key
274
285
// press to the process spawned for temporary integrated consoles when
275
286
// the server requests a cancellation os Console.ReadKey.
276
- //
277
- // TODO: There may be multiple sessions running in parallel, so we need
278
- // to track a process per session, but that already isn't being done.
279
- vscode . debug . onDidReceiveDebugSessionCustomEvent (
287
+ this . debugEventHandler = vscode . debug . onDidReceiveDebugSessionCustomEvent (
280
288
e => {
281
289
if ( e . event === "powerShell/sendKeyPress" ) {
282
290
this . debugSessionProcess . sendKeyPress ( ) ;
0 commit comments