提交 d4be2ab7 编写于 作者: I isidor

debug: start listening on task active event earlier

fixes #37997
上级 30966afc
...@@ -952,12 +952,15 @@ export class DebugService implements debug.IDebugService { ...@@ -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))); 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 => { const promise = this.taskService.getActiveTasks().then(tasks => {
if (tasks.filter(t => t._id === task._id).length) { if (tasks.filter(t => t._id === task._id).length) {
// task is already running - nothing to do. // task is already running - nothing to do.
return TPromise.as(null); return TPromise.as(null);
} }
this.toDispose.push(this.taskService.addOneTimeListener(TaskServiceEvents.Active, () => taskStarted = true));
const taskPromise = this.taskService.run(task); const taskPromise = this.taskService.run(task);
if (task.isBackground) { if (task.isBackground) {
return new TPromise((c, e) => this.toDispose.push(this.taskService.addOneTimeListener(TaskServiceEvents.Inactive, () => c(null)))); 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 { ...@@ -967,14 +970,11 @@ export class DebugService implements debug.IDebugService {
}); });
return new TPromise((c, e) => { 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 => { promise.then(result => {
taskStarted = true; taskStarted = true;
c(result); c(result);
}, error => e(error)); }, error => e(error));
this.toDispose.push(this.taskService.addOneTimeListener(TaskServiceEvents.Active, () => taskStarted = true));
setTimeout(() => { setTimeout(() => {
if (!taskStarted) { if (!taskStarted) {
e({ severity: severity.Error, message: nls.localize('taskNotTracked', "The preLaunchTask '{0}' cannot be tracked.", taskName) }); e({ severity: severity.Error, message: nls.localize('taskNotTracked', "The preLaunchTask '{0}' cannot be tracked.", taskName) });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册