From d4be2ab7b8beb637c79e06c857cba970c23f51bc Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 14 Nov 2017 12:50:28 +0100 Subject: [PATCH] debug: start listening on task active event earlier fixes #37997 --- .../workbench/parts/debug/electron-browser/debugService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 8c2ce64e770..7e2a70c1abc 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -952,12 +952,15 @@ export class DebugService implements debug.IDebugService { return TPromise.wrapError(errors.create(nls.localize('DebugTaskNotFound', "Could not find the preLaunchTask \'{0}\'.", taskName))); } + // If a task is missing the problem matcher the promise will never complete, so we need to have a workaround #35340 + let taskStarted = false; const promise = this.taskService.getActiveTasks().then(tasks => { if (tasks.filter(t => t._id === task._id).length) { // task is already running - nothing to do. return TPromise.as(null); } + this.toDispose.push(this.taskService.addOneTimeListener(TaskServiceEvents.Active, () => taskStarted = true)); const taskPromise = this.taskService.run(task); if (task.isBackground) { return new TPromise((c, e) => this.toDispose.push(this.taskService.addOneTimeListener(TaskServiceEvents.Inactive, () => c(null)))); @@ -967,14 +970,11 @@ export class DebugService implements debug.IDebugService { }); return new TPromise((c, e) => { - // If a task is missing the problem matcher the promise will never complete, so we need to have a workaround #35340 - let taskStarted = false; promise.then(result => { taskStarted = true; c(result); }, error => e(error)); - this.toDispose.push(this.taskService.addOneTimeListener(TaskServiceEvents.Active, () => taskStarted = true)); setTimeout(() => { if (!taskStarted) { e({ severity: severity.Error, message: nls.localize('taskNotTracked', "The preLaunchTask '{0}' cannot be tracked.", taskName) }); -- GitLab