提交 77386544 编写于 作者: A Alex Ross

Fix task instance limit

Part of https://github.com/microsoft/vscode/issues/96999
上级 e941619a
......@@ -229,6 +229,7 @@ export class TerminalTaskSystem implements ITaskSystem {
}
public run(task: Task, resolver: ITaskResolver, trigger: string = Triggers.command): ITaskExecuteResult {
task = task.clone(); // A small amount of task state is stored in the task (instance) and tasks passed in to run may have that set already.
const recentTaskKey = task.getRecentlyUsedKey() ?? '';
let validInstance = task.runOptions && task.runOptions.instanceLimit && this.instances[recentTaskKey] && this.instances[recentTaskKey].instances < task.runOptions.instanceLimit;
let instance = this.instances[recentTaskKey] ? this.instances[recentTaskKey].instances : 0;
......
......@@ -688,6 +688,10 @@ export class CustomTask extends CommonTask {
}
}
public clone(): CustomTask {
return new CustomTask(this._id, this._source, this._label, this.type, this.command, this.hasDefinedMatchers, this.runOptions, this.configurationProperties);
}
public customizes(): KeyedTaskIdentifier | undefined {
if (this._source && this._source.customizes) {
return this._source.customizes;
......@@ -874,6 +878,10 @@ export class ContributedTask extends CommonTask {
this.command = command;
}
public clone(): ContributedTask {
return new ContributedTask(this._id, this._source, this._label, this.type, this.defines, this.command, this.hasDefinedMatchers, this.runOptions, this.configurationProperties);
}
public getDefinition(): KeyedTaskIdentifier {
return this.defines;
}
......@@ -938,6 +946,10 @@ export class InMemoryTask extends CommonTask {
this._source = source;
}
public clone(): InMemoryTask {
return new InMemoryTask(this._id, this._source, this._label, this.type, this.runOptions, this.configurationProperties);
}
public static is(value: any): value is InMemoryTask {
return value instanceof InMemoryTask;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册