@@ -1277,8 +1277,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
1277
1277
}
1278
1278
for ( let i = 0 ; i < this . _reconnectedTerminals . length ; i ++ ) {
1279
1279
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 ( ) ) {
1282
1281
this . _reconnectedTerminals . splice ( i , 1 ) ;
1283
1282
return terminal ;
1284
1283
}
@@ -1323,19 +1322,18 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
1323
1322
this . _logService . trace ( `Already reconnected, to ${ this . _reconnectedTerminals ?. length } terminals so returning` ) ;
1324
1323
return ;
1325
1324
}
1326
- this . _reconnectedTerminals = this . _terminalService . getReconnectedTerminals ( ReconnectionType ) ?. filter ( t => ! t . isDisposed ) ;
1325
+ this . _reconnectedTerminals = this . _terminalService . getReconnectedTerminals ( ReconnectionType ) ?. filter ( t => ! t . isDisposed && getReconnectionData ( t ) ) || [ ] ;
1327
1326
this . _logService . trace ( `Attempting reconnection of ${ this . _reconnectedTerminals ?. length } terminals` ) ;
1328
1327
if ( ! this . _reconnectedTerminals ?. length ) {
1329
1328
this . _logService . trace ( `No terminals to reconnect to so returning` ) ;
1330
1329
} else {
1331
1330
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 ) ;
1336
1336
}
1337
- const terminalData = { lastTask : task . lastTask , group : task . group , terminal } ;
1338
- this . _terminals [ terminal . instanceId ] = terminalData ;
1339
1337
}
1340
1338
}
1341
1339
this . _hasReconnected = true ;
@@ -1839,3 +1837,7 @@ function taskShellIntegrationWaitOnExitSequence(message: string): (exitCode: num
1839
1837
return `${ VSCodeSequence ( VSCodeOscPt . CommandFinished , exitCode . toString ( ) ) } ${ message } ` ;
1840
1838
} ;
1841
1839
}
1840
+
1841
+ function getReconnectionData ( terminal : ITerminalInstance ) : IReconnectionTaskData | undefined {
1842
+ return terminal . shellLaunchConfig . attachPersistentProcess ?. reconnectionProperties ?. data as IReconnectionTaskData | undefined ;
1843
+ }
0 commit comments