diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index c753ef72f2462..10e4324721ba7 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -995,7 +995,7 @@ declare module 'vscode' { * [Pseudoterminal.onDidClose](#Pseudoterminal.onDidClose). * @param callback The callback that will be called when the task is started by a user. */ - constructor(callback: (resolvedDefinition?: TaskDefinition) => Thenable); + constructor(callback: (resolvedDefinition: TaskDefinition) => Thenable); } //#endregion diff --git a/src/vs/workbench/api/browser/mainThreadTask.ts b/src/vs/workbench/api/browser/mainThreadTask.ts index 586acc3ab8d42..d94b7f3dfcb4b 100644 --- a/src/vs/workbench/api/browser/mainThreadTask.ts +++ b/src/vs/workbench/api/browser/mainThreadTask.ts @@ -414,10 +414,16 @@ export class MainThreadTask implements MainThreadTaskShape { ) { this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTask); this._providers = new Map(); - this._taskService.onDidStateChange((event: TaskEvent) => { + this._taskService.onDidStateChange(async (event: TaskEvent) => { const task = event.__task!; if (event.kind === TaskEventKind.Start) { - this._proxy.$onDidStartTask(TaskExecutionDTO.from(task.getTaskExecution()), event.terminalId!); + const execution = TaskExecutionDTO.from(task.getTaskExecution()); + let resolvedDefinition: TaskDefinitionDTO | undefined; + if (execution.task && execution.task.execution && CustomExecutionDTO.is(execution.task.execution)) { + resolvedDefinition = await this._configurationResolverService.resolveWithInteractionReplace(task.getWorkspaceFolder(), + execution.task.definition, 'tasks'); + } + this._proxy.$onDidStartTask(execution, event.terminalId!, resolvedDefinition); } else if (event.kind === TaskEventKind.ProcessStarted) { this._proxy.$onDidStartTaskProcess(TaskProcessStartedDTO.from(task.getTaskExecution(), event.processId!)); } else if (event.kind === TaskEventKind.ProcessEnded) { diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 1c7e49f5c97f4..fcee75d3127fd 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1448,7 +1448,7 @@ export interface ExtHostSCMShape { export interface ExtHostTaskShape { $provideTasks(handle: number, validTypes: { [key: string]: boolean; }): Thenable; $resolveTask(handle: number, taskDTO: tasks.TaskDTO): Thenable; - $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number): void; + $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number, resolvedDefinition?: tasks.TaskDefinitionDTO): void; $onDidStartTaskProcess(value: tasks.TaskProcessStartedDTO): void; $onDidEndTaskProcess(value: tasks.TaskProcessEndedDTO): void; $OnDidEndTask(execution: tasks.TaskExecutionDTO): void; diff --git a/src/vs/workbench/api/common/extHostTask.ts b/src/vs/workbench/api/common/extHostTask.ts index 610e10ec65e22..f77a862606742 100644 --- a/src/vs/workbench/api/common/extHostTask.ts +++ b/src/vs/workbench/api/common/extHostTask.ts @@ -475,11 +475,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask return this._onDidExecuteTask.event; } - protected async resolveDefinition(uri: number | UriComponents | undefined, definition: vscode.TaskDefinition | undefined): Promise { - return definition; - } - - public async $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number): Promise { + public async $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number, resolvedDefinition?: tasks.TaskDefinitionDTO): Promise { const customExecution: types.CustomExecution | undefined = this._providedCustomExecutions2.get(execution.id); if (customExecution) { if (this._activeCustomExecutions2.get(execution.id) !== undefined) { @@ -488,7 +484,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask // Clone the custom execution to keep the original untouched. This is important for multiple runs of the same task. this._activeCustomExecutions2.set(execution.id, customExecution); - this._terminalService.attachPtyToTerminal(terminalId, await customExecution.callback(await this.resolveDefinition(execution.task?.source.scope, execution.task?.definition))); + this._terminalService.attachPtyToTerminal(terminalId, await customExecution.callback(resolvedDefinition)); } this._lastStartedTask = execution.id; diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 311a85fa2b284..0715f6affdb42 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -11,7 +11,6 @@ import * as types from 'vs/workbench/api/common/extHostTypes'; import { IExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace'; import type * as vscode from 'vscode'; import * as tasks from '../common/shared/tasks'; -import * as Objects from 'vs/base/common/objects'; import { ExtHostVariableResolverService } from 'vs/workbench/api/common/extHostDebugService'; import { IExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors'; import { IExtHostConfiguration } from 'vs/workbench/api/common/extHostConfiguration'; @@ -123,32 +122,6 @@ export class ExtHostTask extends ExtHostTaskBase { return this._variableResolver; } - protected async resolveDefinition(uri: number | UriComponents | undefined, definition: vscode.TaskDefinition | undefined): Promise { - if (!uri || (typeof uri === 'number') || !definition) { - return definition; - } - const workspaceFolder = await this._workspaceProvider.resolveWorkspaceFolder(URI.revive(uri)); - const workspaceFolders = await this._workspaceProvider.getWorkspaceFolders2(); - if (!workspaceFolders || !workspaceFolder) { - return definition; - } - const resolver = await this.getVariableResolver(workspaceFolders); - const ws: IWorkspaceFolder = { - uri: workspaceFolder.uri, - name: workspaceFolder.name, - index: workspaceFolder.index, - toResource: () => { - throw new Error('Not implemented'); - } - }; - const resolvedDefinition = Objects.deepClone(definition); - for (const key in resolvedDefinition) { - resolvedDefinition[key] = resolver.resolve(ws, resolvedDefinition[key]); - } - - return resolvedDefinition; - } - public async $resolveVariables(uriComponents: UriComponents, toResolve: { process?: { name: string; cwd?: string; path?: string }, variables: string[] }): Promise<{ process?: string, variables: { [key: string]: string; } }> { const uri: URI = URI.revive(uriComponents); const result = {