Skip to content

Commit

Permalink
debug: start listening on task active event earlier
Browse files Browse the repository at this point in the history
fixes #37997
  • Loading branch information
isidorn committed Nov 14, 2017
1 parent 30966af commit d4be2ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/vs/workbench/parts/debug/electron-browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
Expand All @@ -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) });
Expand Down

0 comments on commit d4be2ab

Please sign in to comment.