Skip to content

Commit 9362739

Browse files
authored
add terminal to taskExecution (microsoft#254477)
fix microsoft#234440
1 parent 45bcb2d commit 9362739

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

src/vs/platform/extensions/common/extensionsApiProposals.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ const _allApiProposals = {
344344
tabInputTextMerge: {
345345
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tabInputTextMerge.d.ts',
346346
},
347+
taskExecutionTerminal: {
348+
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.taskExecutionTerminal.d.ts',
349+
},
347350
taskPresentationGroup: {
348351
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.taskPresentationGroup.d.ts',
349352
},

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
13581358
return extHostTask.taskExecutions;
13591359
},
13601360
onDidStartTask: (listeners, thisArgs?, disposables?) => {
1361+
if (!isProposedApiEnabled(extension, 'taskExecutionTerminal')) {
1362+
thisArgs.terminal = undefined;
1363+
}
13611364
return _asExtensionEvent(extHostTask.onDidStartTask)(listeners, thisArgs, disposables);
13621365
},
13631366
onDidEndTask: (listeners, thisArgs?, disposables?) => {

src/vs/workbench/api/common/extHostTask.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ namespace TaskFilterDTO {
360360
class TaskExecutionImpl implements vscode.TaskExecution {
361361

362362
readonly #tasks: ExtHostTaskBase;
363+
private _terminal: vscode.Terminal | undefined;
363364

364365
constructor(tasks: ExtHostTaskBase, readonly _id: string, private readonly _task: vscode.Task) {
365366
this.#tasks = tasks;
@@ -378,6 +379,14 @@ class TaskExecutionImpl implements vscode.TaskExecution {
378379

379380
public fireDidEndProcess(value: tasks.ITaskProcessEndedDTO): void {
380381
}
382+
383+
public get terminal(): vscode.Terminal | undefined {
384+
return this._terminal;
385+
}
386+
387+
public set terminal(term: vscode.Terminal | undefined) {
388+
this._terminal = term;
389+
}
381390
}
382391

383392
export interface HandlerData {
@@ -497,8 +506,14 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
497506
}
498507
this._lastStartedTask = execution.id;
499508

509+
const taskExecution = await this.getTaskExecution(execution);
510+
const terminal = this._terminalService.getTerminalById(terminalId)?.value;
511+
if (taskExecution) {
512+
taskExecution.terminal = terminal;
513+
}
514+
500515
this._onDidExecuteTask.fire({
501-
execution: await this.getTaskExecution(execution)
516+
execution: taskExecution
502517
});
503518
}
504519

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
// #234440
7+
declare module 'vscode' {
8+
9+
export interface TaskExecution {
10+
/**
11+
* The terminal associated with this task execution, if any.
12+
*/
13+
readonly terminal?: Terminal;
14+
}
15+
}

0 commit comments

Comments
 (0)