@@ -1277,8 +1277,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
12771277 }
12781278 for ( let i = 0 ; i < this . _reconnectedTerminals . length ; i ++ ) {
12791279 const terminal = this . _reconnectedTerminals [ i ] ;
1280- const taskForTerminal = terminal . shellLaunchConfig . attachPersistentProcess ?. reconnectionProperties ?. data as IReconnectionTaskData ;
1281- if ( taskForTerminal . lastTask === task . getCommonTaskId ( ) ) {
1280+ if ( getReconnectionData ( terminal ) ?. lastTask === task . getCommonTaskId ( ) ) {
12821281 this . _reconnectedTerminals . splice ( i , 1 ) ;
12831282 return terminal ;
12841283 }
@@ -1323,19 +1322,18 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
13231322 this . _logService . trace ( `Already reconnected, to ${ this . _reconnectedTerminals ?. length } terminals so returning` ) ;
13241323 return ;
13251324 }
1326- this . _reconnectedTerminals = this . _terminalService . getReconnectedTerminals ( ReconnectionType ) ?. filter ( t => ! t . isDisposed ) ;
1325+ this . _reconnectedTerminals = this . _terminalService . getReconnectedTerminals ( ReconnectionType ) ?. filter ( t => ! t . isDisposed && getReconnectionData ( t ) ) || [ ] ;
13271326 this . _logService . trace ( `Attempting reconnection of ${ this . _reconnectedTerminals ?. length } terminals` ) ;
13281327 if ( ! this . _reconnectedTerminals ?. length ) {
13291328 this . _logService . trace ( `No terminals to reconnect to so returning` ) ;
13301329 } else {
13311330 for ( const terminal of this . _reconnectedTerminals ) {
1332- const task = terminal . shellLaunchConfig . attachPersistentProcess ?. reconnectionProperties ?. data as IReconnectionTaskData ;
1333- this . _logService . trace ( `Reconnecting to task: ${ JSON . stringify ( task ) } ` ) ;
1334- if ( ! task ) {
1335- continue ;
1331+ const data = getReconnectionData ( terminal ) as IReconnectionTaskData | undefined ;
1332+ if ( data ) {
1333+ const terminalData = { lastTask : data . lastTask , group : data . group , terminal } ;
1334+ this . _terminals [ terminal . instanceId ] = terminalData ;
1335+ this . _logService . trace ( 'Reconnecting to task terminal' , terminalData . lastTask , terminal . instanceId ) ;
13361336 }
1337- const terminalData = { lastTask : task . lastTask , group : task . group , terminal } ;
1338- this . _terminals [ terminal . instanceId ] = terminalData ;
13391337 }
13401338 }
13411339 this . _hasReconnected = true ;
@@ -1839,3 +1837,7 @@ function taskShellIntegrationWaitOnExitSequence(message: string): (exitCode: num
18391837 return `${ VSCodeSequence ( VSCodeOscPt . CommandFinished , exitCode . toString ( ) ) } ${ message } ` ;
18401838 } ;
18411839}
1840+
1841+ function getReconnectionData ( terminal : ITerminalInstance ) : IReconnectionTaskData | undefined {
1842+ return terminal . shellLaunchConfig . attachPersistentProcess ?. reconnectionProperties ?. data as IReconnectionTaskData | undefined ;
1843+ }
0 commit comments