提交 e7921a0d 编写于 作者: I isidor

Debug: fix debt around preLaunchTask

fixes #31674
上级 5a0d16d8
......@@ -38,7 +38,7 @@ import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel';
import * as debugactions from 'vs/workbench/parts/debug/browser/debugActions';
import { ConfigurationManager } from 'vs/workbench/parts/debug/electron-browser/debugConfigurationManager';
import { ToggleMarkersPanelAction } from 'vs/workbench/parts/markers/browser/markersPanelActions';
import { ITaskService, TaskEvent, TaskType, TaskServiceEvents, ITaskSummary } from 'vs/workbench/parts/tasks/common/taskService';
import { ITaskService, TaskServiceEvents, ITaskSummary } from 'vs/workbench/parts/tasks/common/taskService';
import { TaskError } from 'vs/workbench/parts/tasks/common/taskSystem';
import { VIEWLET_ID as EXPLORER_VIEWLET_ID } from 'vs/workbench/parts/files/common/files';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
......@@ -75,7 +75,6 @@ export class DebugService implements debug.IDebugService {
private allSessionIds: Set<string>;
private configurationManager: ConfigurationManager;
private customTelemetryService: ITelemetryService;
private lastTaskEvent: TaskEvent;
private toDispose: lifecycle.IDisposable[];
private toDisposeOnSessionEnd: Map<string, lifecycle.IDisposable[]>;
private inDebugMode: IContextKey<boolean>;
......@@ -135,24 +134,8 @@ export class DebugService implements debug.IDebugService {
private registerListeners(lifecycleService: ILifecycleService): void {
this.toDispose.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
if (this.taskService) {
this.toDispose.push(this.taskService.addListener(TaskServiceEvents.Active, (e: TaskEvent) => {
this.lastTaskEvent = e;
}));
this.toDispose.push(this.taskService.addListener(TaskServiceEvents.Inactive, (e: TaskEvent) => {
if (e.type === TaskType.SingleRun) {
this.lastTaskEvent = null;
}
}));
this.toDispose.push(this.taskService.addListener(TaskServiceEvents.Terminated, (e: TaskEvent) => {
this.lastTaskEvent = null;
}));
}
lifecycleService.onShutdown(this.store, this);
lifecycleService.onShutdown(this.dispose, this);
this.toDispose.push(this.broadcastService.onBroadcast(this.onBroadcast, this));
}
......@@ -907,30 +890,20 @@ export class DebugService implements debug.IDebugService {
return TPromise.wrapError(errors.create(nls.localize('DebugTaskNotFound', "Could not find the preLaunchTask \'{0}\'.", taskName)));
}
return this.taskService.getActiveTasks().then(tasks => {
if (tasks.filter(t => t._id === task._id).length) {
// task is already running - nothing to do.
if (this.lastTaskEvent && this.lastTaskEvent.taskId === task._id) {
return TPromise.as(null);
}
if (this.lastTaskEvent) {
// there is a different task running currently.
return TPromise.wrapError(errors.create(nls.localize('differentTaskRunning', "The task '{0}' is already running. Cannot run pre-launch task '{1}'.", this.lastTaskEvent.taskName, taskName)));
}
// no task running, execute the preLaunchTask.
const taskPromise = this.taskService.run(task).then(result => {
this.lastTaskEvent = null;
return result;
}, err => {
this.lastTaskEvent = null;
});
const taskPromise = this.taskService.run(task);
if (task.isBackground) {
return new TPromise((c, e) => this.taskService.addOneTimeListener(TaskServiceEvents.Inactive, () => c(null)));
}
return taskPromise;
});
});
}
public sourceIsNotAvailable(uri: uri): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册