Skip to content

Commit 96b89dd

Browse files
authored
Fix task instance limit (#97011)
Fixes #96999
1 parent d4b8ec9 commit 96b89dd

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export class TerminalTaskSystem implements ITaskSystem {
229229
}
230230

231231
public run(task: Task, resolver: ITaskResolver, trigger: string = Triggers.command): ITaskExecuteResult {
232+
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.
232233
const recentTaskKey = task.getRecentlyUsedKey() ?? '';
233234
let validInstance = task.runOptions && task.runOptions.instanceLimit && this.instances[recentTaskKey] && this.instances[recentTaskKey].instances < task.runOptions.instanceLimit;
234235
let instance = this.instances[recentTaskKey] ? this.instances[recentTaskKey].instances : 0;

src/vs/workbench/contrib/tasks/common/tasks.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,10 @@ export class CustomTask extends CommonTask {
688688
}
689689
}
690690

691+
public clone(): CustomTask {
692+
return new CustomTask(this._id, this._source, this._label, this.type, this.command, this.hasDefinedMatchers, this.runOptions, this.configurationProperties);
693+
}
694+
691695
public customizes(): KeyedTaskIdentifier | undefined {
692696
if (this._source && this._source.customizes) {
693697
return this._source.customizes;
@@ -874,6 +878,10 @@ export class ContributedTask extends CommonTask {
874878
this.command = command;
875879
}
876880

881+
public clone(): ContributedTask {
882+
return new ContributedTask(this._id, this._source, this._label, this.type, this.defines, this.command, this.hasDefinedMatchers, this.runOptions, this.configurationProperties);
883+
}
884+
877885
public getDefinition(): KeyedTaskIdentifier {
878886
return this.defines;
879887
}
@@ -938,6 +946,10 @@ export class InMemoryTask extends CommonTask {
938946
this._source = source;
939947
}
940948

949+
public clone(): InMemoryTask {
950+
return new InMemoryTask(this._id, this._source, this._label, this.type, this.runOptions, this.configurationProperties);
951+
}
952+
941953
public static is(value: any): value is InMemoryTask {
942954
return value instanceof InMemoryTask;
943955
}

0 commit comments

Comments
 (0)