@@ -50,6 +50,7 @@ export class SessionManager implements Middleware {
5050 private statusBarItem : vscode . StatusBarItem ;
5151 private languageServerProcess : PowerShellProcess ;
5252 private debugSessionProcess : PowerShellProcess ;
53+ private debugEventHandler : vscode . Disposable ;
5354 private versionDetails : IPowerShellVersionDetails ;
5455 private registeredCommands : vscode . Disposable [ ] = [ ] ;
5556 private languageServerClient : LanguageClient = undefined ;
@@ -228,9 +229,10 @@ export class SessionManager implements Middleware {
228229 this . languageServerClient = undefined ;
229230 }
230231
231- // Kill the PowerShell proceses we spawned
232+ // Kill the PowerShell process we spawned
232233 if ( this . debugSessionProcess ) {
233234 this . debugSessionProcess . dispose ( ) ;
235+ this . debugEventHandler . dispose ( ) ;
234236 }
235237 if ( this . languageServerProcess ) {
236238 this . languageServerProcess . dispose ( ) ;
@@ -260,6 +262,15 @@ export class SessionManager implements Middleware {
260262 sessionPath : string ,
261263 sessionSettings : Settings . ISettings ) : PowerShellProcess {
262264
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+
263274 this . debugSessionProcess =
264275 new PowerShellProcess (
265276 this . PowerShellExeDetails . exePath ,
@@ -273,10 +284,7 @@ export class SessionManager implements Middleware {
273284 // Similar to the regular integrated console, we need to send a key
274285 // press to the process spawned for temporary integrated consoles when
275286 // 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 (
280288 e => {
281289 if ( e . event === "powerShell/sendKeyPress" ) {
282290 this . debugSessionProcess . sendKeyPress ( ) ;
0 commit comments