diff --git a/src/vs/workbench/api/browser/mainThreadTerminalService.ts b/src/vs/workbench/api/browser/mainThreadTerminalService.ts index b79eb926d98..3df20a04d66 100644 --- a/src/vs/workbench/api/browser/mainThreadTerminalService.ts +++ b/src/vs/workbench/api/browser/mainThreadTerminalService.ts @@ -242,10 +242,8 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape commandLine: e.data.command, // TODO: Convert to URI if possible cwd: e.data.cwd, - result: { - exitCode: e.data.exitCode, - output: e.data.getOutput() ?? '' - } + exitCode: e.data.exitCode, + output: e.data.getOutput() }); }); this._sendCommandEventListener.value = multiplexer; @@ -334,10 +332,6 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape this._proxy.$acceptTerminalProcessData(terminalId, data); } - // private _onWillExecuteCommand(terminalId: number, command: ITerminalCommandDto): void { - // this._proxy.$acceptWillExecuteCommand(terminalId, command); - // } - private _onDidExecuteCommand(terminalId: number, command: ITerminalCommandDto): void { this._proxy.$acceptDidExecuteCommand(terminalId, command); } diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index e04d6de10a3..f0720ab47a3 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -698,11 +698,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I checkProposedApiEnabled(extension, 'terminalDataWriteEvent'); return extHostTerminalService.onDidWriteTerminalData(listener, thisArg, disposables); }, - onWillExecuteTerminalCommand(listener, thisArg?, disposables?) { - checkProposedApiEnabled(extension, 'terminalExecuteCommandEvent'); - return extHostTerminalService.onWillExecuteTerminalCommand(listener, thisArg, disposables); - - }, onDidExecuteTerminalCommand(listener, thisArg?, disposables?) { checkProposedApiEnabled(extension, 'terminalExecuteCommandEvent'); return extHostTerminalService.onDidExecuteTerminalCommand(listener, thisArg, disposables); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index d1bc7c19b5d..344df01f4e8 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -2092,12 +2092,10 @@ export interface TerminalCommandMatchResultDto { } export interface ITerminalCommandDto { - commandLine: string; + commandLine: string | undefined; cwd: URI | string | undefined; - result: { - exitCode: number | undefined; - output: string; - }; + exitCode: number | undefined; + output: string | undefined; } export interface ExtHostTerminalServiceShape { @@ -2106,7 +2104,6 @@ export interface ExtHostTerminalServiceShape { $acceptActiveTerminalChanged(id: number | null): void; $acceptTerminalProcessId(id: number, processId: number): void; $acceptTerminalProcessData(id: number, data: string): void; - $acceptWillExecuteCommand(id: number, command: ITerminalCommandDto): void; $acceptDidExecuteCommand(id: number, command: ITerminalCommandDto): void; $acceptTerminalTitleChange(id: number, name: string): void; $acceptTerminalDimensions(id: number, cols: number, rows: number): void; diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index 12f822bc5bb..51316b974cc 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -5,7 +5,7 @@ import type * as vscode from 'vscode'; import { Event, Emitter } from 'vs/base/common/event'; -import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, ITerminalDimensionsDto, ITerminalLinkDto, ExtHostTerminalIdentifier, ICommandDto, ITerminalQuickFixOpenerDto, ITerminalQuickFixExecuteTerminalCommandDto, TerminalCommandMatchResultDto } from 'vs/workbench/api/common/extHost.protocol'; +import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, ITerminalDimensionsDto, ITerminalLinkDto, ExtHostTerminalIdentifier, ICommandDto, ITerminalQuickFixOpenerDto, ITerminalQuickFixExecuteTerminalCommandDto, TerminalCommandMatchResultDto, ITerminalCommandDto } from 'vs/workbench/api/common/extHost.protocol'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { URI } from 'vs/base/common/uri'; import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService'; @@ -40,8 +40,7 @@ export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, ID readonly onDidChangeTerminalDimensions: Event; readonly onDidChangeTerminalState: Event; readonly onDidWriteTerminalData: Event; - readonly onWillExecuteTerminalCommand: Event; - readonly onDidExecuteTerminalCommand: Event; + readonly onDidExecuteTerminalCommand: Event; readonly onDidChangeShell: Event; createTerminal(name?: string, shellPath?: string, shellArgs?: readonly string[] | string): vscode.Terminal; @@ -403,12 +402,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I onDidRemoveLastListener: () => this._proxy.$stopSendingDataEvents() }); readonly onDidWriteTerminalData = this._onDidWriteTerminalData.event; - protected readonly _onWillExecuteCommand = new Emitter({ - onWillAddFirstListener: () => this._proxy.$startSendingCommandEvents(), - onDidRemoveLastListener: () => this._proxy.$stopSendingCommandEvents() - }); - readonly onWillExecuteTerminalCommand = this._onWillExecuteCommand.event; - protected readonly _onDidExecuteCommand = new Emitter({ + protected readonly _onDidExecuteCommand = new Emitter({ onWillAddFirstListener: () => this._proxy.$startSendingCommandEvents(), onDidRemoveLastListener: () => this._proxy.$stopSendingCommandEvents() }); @@ -521,23 +515,10 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I } } - public async $acceptWillExecuteCommand(id: number, command: any): Promise { + public async $acceptDidExecuteCommand(id: number, command: ITerminalCommandDto): Promise { const terminal = this._getTerminalById(id); if (terminal) { - this._onWillExecuteCommand.fire({ - terminal: terminal.value, - command: command - }); - } - } - - public async $acceptDidExecuteCommand(id: number, command: any): Promise { - const terminal = this._getTerminalById(id); - if (terminal) { - this._onDidExecuteCommand.fire({ - terminal: terminal.value, - command: command - }); + this._onDidExecuteCommand.fire({ terminal: terminal.value, ...command }); } } diff --git a/src/vscode-dts/vscode.proposed.terminalExecuteCommandEvent.d.ts b/src/vscode-dts/vscode.proposed.terminalExecuteCommandEvent.d.ts index 09e8146a10d..4b3aa64400e 100644 --- a/src/vscode-dts/vscode.proposed.terminalExecuteCommandEvent.d.ts +++ b/src/vscode-dts/vscode.proposed.terminalExecuteCommandEvent.d.ts @@ -7,17 +7,7 @@ declare module 'vscode' { // https://github.com/microsoft/vscode/issues/145234 - export interface TerminalWillExecuteCommandEvent { - terminal: Terminal; - command: TerminalCommand>; - } - - export interface TerminalExecuteCommandEvent { - terminal: Terminal; - command: TerminalCommand; - } - - export interface TerminalCommand> { + export interface TerminalExecutedCommand { /** * The {@link Terminal} the command was executed in. */ @@ -25,44 +15,32 @@ declare module 'vscode' { /** * The full command line that was executed, including both the command and the arguments. */ - commandLine: string; + commandLine: string | undefined; /** * The current working directory that was reported by the shell. This will be a {@link Uri} * if the string reported by the shell can reliably be mapped to the connected machine. */ cwd: Uri | string | undefined; - /** - * The result of the command. - */ - result: T; - } - - export interface TerminalExecuteCommandResult { /** * The exit code reported by the shell. */ - exitCode: number; + exitCode: number | undefined; /** * The output of the command when it has finished executing. This is the plain text shown in * the terminal buffer and does not include raw escape sequences. Depending on the shell * setup, this may include the command line as part of the output. */ - output: string; + output: string | undefined; } export namespace window { - /** - * An event that is emitted when a terminal with shell integration activated has started - * executing a command. - */ - export const onWillExecuteTerminalCommand: Event; /** * An event that is emitted when a terminal with shell integration activated has completed * executing a command. * * Note that this event will not fire if the executed command exits the shell, listen to - * {@link onDidOpenTerminal} to handle that case. + * {@link onDidCloseTerminal} to handle that case. */ - export const onDidExecuteTerminalCommand: Event; + export const onDidExecuteTerminalCommand: Event; } }