From 406a5c9954fb52567def7e12b29d28a1ce6a07d9 Mon Sep 17 00:00:00 2001 From: Gabriel DeBacker Date: Wed, 14 Aug 2019 09:11:53 -0700 Subject: [PATCH 1/3] Do not clear out the map, and track the provided execution during execute task --- src/vs/workbench/api/node/extHostTask.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 647a2be3f08db..08f61539e79ec 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -444,6 +444,14 @@ export class ExtHostTask implements ExtHostTaskShape { if (dto === undefined) { return Promise.reject(new Error('Task is not valid')); } + + // If this task is a custom execution, then we need to save it away + // in the provided custom execution map that is cleaned up after the + // task is executed. + if (CustomExecution2DTO.is(dto.execution)) { + await this.addCustomExecution2(dto, task); + } + return this._proxy.$executeTask(dto).then(value => this.getTaskExecution(value, task)); } } @@ -529,11 +537,6 @@ export class ExtHostTask implements ExtHostTaskShape { return Promise.reject(new Error('no handler found')); } - // For custom execution tasks, we need to store the execution objects locally - // since we obviously cannot send callback functions through the proxy. - // So, clear out any existing ones. - this._providedCustomExecutions2.clear(); - // Set up a list of task ID promises that we can wait on // before returning the provided tasks. The ensures that // our task IDs are calculated for any custom execution tasks. From fb3867479517ad58b75b1bddb6ebebc603a24e8e Mon Sep 17 00:00:00 2001 From: Gabriel DeBacker Date: Wed, 14 Aug 2019 09:27:11 -0700 Subject: [PATCH 2/3] Clear provided custom executions map on execution complete --- src/vs/workbench/api/node/extHostTask.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 08f61539e79ec..99e3ffb8cf4c1 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -695,5 +695,11 @@ export class ExtHostTask implements ExtHostTaskShape { if (extensionCallback2) { this._activeCustomExecutions2.delete(execution.id); } + + // Technically we don't really need to do this, however, if an extension + // is executing a task through "executeTask" over and over again + // with different properties in the task definition, then this list + // could grow indefinitely, something we don't want. + this._providedCustomExecutions2.clear(); } } From df89de996c1e80930677aaa00d71ebfc8d72238e Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 15 Aug 2019 11:37:05 +0200 Subject: [PATCH 3/3] Save last custom execution --- src/vs/workbench/api/node/extHostTask.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 99e3ffb8cf4c1..cf9b522ef1113 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -696,10 +696,16 @@ export class ExtHostTask implements ExtHostTaskShape { this._activeCustomExecutions2.delete(execution.id); } + const lastCustomExecution = this._providedCustomExecutions2.get(execution.id); // Technically we don't really need to do this, however, if an extension // is executing a task through "executeTask" over and over again // with different properties in the task definition, then this list // could grow indefinitely, something we don't want. this._providedCustomExecutions2.clear(); + // We do still need to hang on to the last custom execution so that the + // Rerun Task command doesn't choke when it tries to rerun a custom execution + if (lastCustomExecution) { + this._providedCustomExecutions2.set(execution.id, lastCustomExecution); + } } }