diff --git a/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts b/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts index 88c773aa7ee..6197b74a44d 100644 --- a/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts +++ b/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts @@ -28,9 +28,10 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut @IWorkspaceTrustManagementService private readonly _workspaceTrustManagementService: IWorkspaceTrustManagementService, @ILogService private readonly _logService: ILogService) { super(); - this._taskService.onDidReconnectToTasks((() => this._tryRunTasks())); if (this._taskService.isReconnected) { this._tryRunTasks(); + } else { + this._register(Event.once(this._taskService.onDidReconnectToTasks)(() => this._tryRunTasks())); } this._register(this._workspaceTrustManagementService.onDidChangeTrust(async trusted => { if (trusted) {