@@ -53,7 +53,7 @@ import { ITaskExecuteResult, ITaskResolver, ITaskSummary, ITaskSystem, ITaskSyst
53
53
import { getTemplates as getTaskTemplates } from 'vs/workbench/contrib/tasks/common/taskTemplates' ;
54
54
55
55
import * as TaskConfig from '../common/taskConfiguration' ;
56
- import { terminalsNotReconnectedExitCode , TerminalTaskSystem } from './terminalTaskSystem' ;
56
+ import { TerminalTaskSystem } from './terminalTaskSystem' ;
57
57
58
58
import { IQuickInputService , IQuickPick , IQuickPickItem , IQuickPickSeparator , QuickPickInput } from 'vs/platform/quickinput/common/quickInput' ;
59
59
@@ -181,11 +181,6 @@ class TaskMap {
181
181
}
182
182
}
183
183
184
- interface EventBarrier {
185
- isOpen : boolean ;
186
- queuedEvent ?: boolean ;
187
- }
188
-
189
184
export abstract class AbstractTaskService extends Disposable implements ITaskService {
190
185
191
186
// private static autoDetectTelemetryName: string = 'taskServer.autoDetect';
@@ -200,8 +195,6 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
200
195
201
196
private static _nextHandle : number = 0 ;
202
197
203
- private _reconnectionBarrier : EventBarrier = { isOpen : true } ;
204
-
205
198
private _tasksReconnected : boolean = false ;
206
199
private _schemaVersion : JsonSchemaVersion | undefined ;
207
200
private _executionEngine : ExecutionEngine | undefined ;
@@ -337,12 +330,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
337
330
this . _waitForSupportedExecutions = new Promise ( resolve => {
338
331
once ( this . _onDidRegisterSupportedExecutions . event ) ( ( ) => resolve ( ) ) ;
339
332
} ) ;
340
- this . _register ( this . onDidReconnectToTerminals ( async ( ) => {
341
- await this . _waitForSupportedExecutions ;
342
- await this . _attemptTaskReconnection ( ) ;
343
- } ) ) ;
344
-
345
- this . _register ( this . _onDidRegisterSupportedExecutions . event ( async ( ) => await this . _attemptTaskReconnection ( ) ) ) ;
333
+ if ( this . _terminalService . getReconnectedTerminals ( 'Task' ) ) {
334
+ this . _attemptTaskReconnection ( ) ;
335
+ } else {
336
+ this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _attemptTaskReconnection ( ) ) ) ;
337
+ }
346
338
this . _upgrade ( ) ;
347
339
}
348
340
@@ -363,25 +355,17 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
363
355
this . _onDidRegisterSupportedExecutions . fire ( ) ;
364
356
}
365
357
366
- private async _attemptTaskReconnection ( ) : Promise < void > {
367
- if ( ! this . _reconnectionBarrier . isOpen ) {
368
- this . _reconnectionBarrier . queuedEvent = true ;
369
- return ;
370
- }
371
- this . _reconnectionBarrier . isOpen = false ;
372
- if ( ! this . _taskSystem ) {
373
- this . _logService . info ( 'getting task system before reconnection' ) ;
374
- await this . _getTaskSystem ( ) ;
375
- }
376
- this . _logService . info ( `attempting task reconnection, jsonTasksSupported: ${ this . _jsonTasksSupported } , reconnection pending ${ ! this . _tasksReconnected } ` ) ;
377
- if ( this . _configurationService . getValue ( TaskSettingId . Reconnection ) === true && ! this . _tasksReconnected ) {
378
- this . _tasksReconnected = await this . _reconnectTasks ( ) ;
379
- }
380
- this . _reconnectionBarrier . isOpen = true ;
381
- if ( this . _reconnectionBarrier . queuedEvent ) {
382
- this . _reconnectionBarrier . queuedEvent = undefined ;
383
- await this . _attemptTaskReconnection ( ) ;
384
- }
358
+ private _attemptTaskReconnection ( ) : void {
359
+ this . _getTaskSystem ( ) ;
360
+ 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
+ } ) ;
367
+ } ) ;
368
+ } ) ;
385
369
}
386
370
387
371
private async _reconnectTasks ( ) : Promise < boolean > {
@@ -390,23 +374,19 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
390
374
this . _storageService . remove ( AbstractTaskService . PersistentTasks_Key , StorageScope . WORKSPACE ) ;
391
375
return true ;
392
376
}
377
+
393
378
const tasks = await this . getSavedTasks ( 'persistent' ) ;
394
379
if ( ! tasks . length ) {
395
380
return true ;
396
381
}
397
382
for ( const task of tasks ) {
398
- let result ;
399
383
if ( ConfiguringTask . is ( task ) ) {
400
384
const resolved = await this . tryResolveTask ( task ) ;
401
385
if ( resolved ) {
402
- result = await this . run ( resolved , undefined , TaskRunSource . Reconnect ) ;
386
+ this . run ( resolved , undefined , TaskRunSource . Reconnect ) ;
403
387
}
404
388
} else {
405
- result = await this . run ( task , undefined , TaskRunSource . Reconnect ) ;
406
- }
407
- if ( result ?. exitCode === terminalsNotReconnectedExitCode ) {
408
- this . _logService . trace ( 'Terminals were not reconnected' ) ;
409
- return false ;
389
+ this . run ( task , undefined , TaskRunSource . Reconnect ) ;
410
390
}
411
391
}
412
392
return true ;
0 commit comments