@@ -330,11 +330,16 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
330
330
this . _waitForSupportedExecutions = new Promise ( resolve => {
331
331
once ( this . _onDidRegisterSupportedExecutions . event ) ( ( ) => resolve ( ) ) ;
332
332
} ) ;
333
- if ( this . _terminalService . getReconnectedTerminals ( 'Task' ) ) {
333
+ if ( this . _terminalService . getReconnectedTerminals ( 'Task' ) ?. length ) {
334
334
this . _attemptTaskReconnection ( ) ;
335
335
} else {
336
- this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _attemptTaskReconnection ( ) ) ) ;
336
+ this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => {
337
+ if ( this . _terminalService . getReconnectedTerminals ( 'Task' ) ?. length ) {
338
+ this . _attemptTaskReconnection ( ) ;
339
+ }
340
+ } ) ) ;
337
341
}
342
+
338
343
this . _upgrade ( ) ;
339
344
}
340
345
@@ -356,25 +361,23 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
356
361
}
357
362
358
363
private _attemptTaskReconnection ( ) : void {
364
+ if ( this . _lifecycleService . startupKind !== StartupKind . ReloadedWindow ) {
365
+ this . _tasksReconnected = true ;
366
+ this . _storageService . remove ( AbstractTaskService . PersistentTasks_Key , StorageScope . WORKSPACE ) ;
367
+ }
368
+ if ( ! this . _configurationService . getValue ( TaskSettingId . Reconnection ) || this . _tasksReconnected ) {
369
+ this . _tasksReconnected = true ;
370
+ return ;
371
+ }
359
372
this . _getTaskSystem ( ) ;
360
373
this . _waitForSupportedExecutions . then ( ( ) => {
361
- this . _activateTaskProviders ( undefined ) . then ( ( ) => {
362
- this . getWorkspaceTasks ( ) . then ( async ( ) => {
363
- if ( this . _configurationService . getValue ( TaskSettingId . Reconnection ) === true && ! this . _tasksReconnected ) {
364
- await this . _reconnectTasks ( ) ;
365
- }
366
- } ) ;
374
+ this . getWorkspaceTasks ( ) . then ( async ( ) => {
375
+ this . _tasksReconnected = await this . _reconnectTasks ( ) ;
367
376
} ) ;
368
377
} ) ;
369
378
}
370
379
371
380
private async _reconnectTasks ( ) : Promise < boolean > {
372
- if ( this . _lifecycleService . startupKind !== StartupKind . ReloadedWindow ) {
373
- this . _tasksReconnected = true ;
374
- this . _storageService . remove ( AbstractTaskService . PersistentTasks_Key , StorageScope . WORKSPACE ) ;
375
- return true ;
376
- }
377
-
378
381
const tasks = await this . getSavedTasks ( 'persistent' ) ;
379
382
if ( ! tasks . length ) {
380
383
return true ;
0 commit comments