Skip to content

Commit 314775d

Browse files
committed
Create TerminalShellExecutionStartEvent
1 parent b84bae9 commit 314775d

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface IExtHostTerminalShellIntegration extends ExtHostTerminalShellIn
1818
readonly _serviceBrand: undefined;
1919

2020
readonly onDidChangeTerminalShellIntegration: Event<vscode.TerminalShellIntegrationChangeEvent>;
21-
readonly onDidStartTerminalShellExecution: Event<vscode.TerminalShellExecution>;
21+
readonly onDidStartTerminalShellExecution: Event<vscode.TerminalShellExecutionStartEvent>;
2222
readonly onDidEndTerminalShellExecution: Event<vscode.TerminalShellExecutionEndEvent>;
2323
}
2424
export const IExtHostTerminalShellIntegration = createDecorator<IExtHostTerminalShellIntegration>('IExtHostTerminalShellIntegration');
@@ -33,7 +33,7 @@ export class ExtHostTerminalShellIntegration extends Disposable implements IExtH
3333

3434
protected readonly _onDidChangeTerminalShellIntegration = new Emitter<vscode.TerminalShellIntegrationChangeEvent>();
3535
readonly onDidChangeTerminalShellIntegration = this._onDidChangeTerminalShellIntegration.event;
36-
protected readonly _onDidStartTerminalShellExecution = new Emitter<vscode.TerminalShellExecution>();
36+
protected readonly _onDidStartTerminalShellExecution = new Emitter<vscode.TerminalShellExecutionStartEvent>();
3737
readonly onDidStartTerminalShellExecution = this._onDidStartTerminalShellExecution.event;
3838
protected readonly _onDidEndTerminalShellExecution = new Emitter<vscode.TerminalShellExecutionEndEvent>();
3939
readonly onDidEndTerminalShellExecution = this._onDidEndTerminalShellExecution.event;
@@ -162,7 +162,7 @@ class InternalTerminalShellIntegration extends Disposable {
162162

163163
constructor(
164164
private readonly _terminal: vscode.Terminal,
165-
private readonly _onDidStartTerminalShellExecution: Emitter<vscode.TerminalShellExecution>
165+
private readonly _onDidStartTerminalShellExecution: Emitter<vscode.TerminalShellExecutionStartEvent>
166166
) {
167167
super();
168168

@@ -200,13 +200,13 @@ class InternalTerminalShellIntegration extends Disposable {
200200
} else {
201201
if (this._currentExecution) {
202202
this._currentExecution.endExecution(undefined);
203-
this._onDidRequestEndExecution.fire({ execution: this._currentExecution.value, exitCode: undefined });
203+
this._onDidRequestEndExecution.fire({ terminal: this._terminal, shellIntegration: this.value, execution: this._currentExecution.value, exitCode: undefined });
204204
}
205-
const currentExecution = this._currentExecution = new InternalTerminalShellExecution(this._terminal, commandLine, cwd);
205+
const currentExecution = this._currentExecution = new InternalTerminalShellExecution(commandLine, cwd);
206206
if (fireEventInMicrotask) {
207-
queueMicrotask(() => this._onDidStartTerminalShellExecution.fire(currentExecution.value));
207+
queueMicrotask(() => this._onDidStartTerminalShellExecution.fire({ terminal: this._terminal, shellIntegration: this.value, execution: currentExecution.value }));
208208
} else {
209-
this._onDidStartTerminalShellExecution.fire(this._currentExecution.value);
209+
this._onDidStartTerminalShellExecution.fire({ terminal: this._terminal, shellIntegration: this.value, execution: this._currentExecution.value });
210210
}
211211
}
212212
return this._currentExecution;
@@ -219,7 +219,7 @@ class InternalTerminalShellIntegration extends Disposable {
219219
endShellExecution(commandLine: vscode.TerminalShellExecutionCommandLine | undefined, exitCode: number | undefined): void {
220220
if (this._currentExecution) {
221221
this._currentExecution.endExecution(commandLine);
222-
this._onDidRequestEndExecution.fire({ execution: this._currentExecution.value, exitCode });
222+
this._onDidRequestEndExecution.fire({ terminal: this._terminal, shellIntegration: this.value, execution: this._currentExecution.value, exitCode });
223223
this._currentExecution = undefined;
224224
}
225225
}
@@ -246,15 +246,11 @@ class InternalTerminalShellExecution {
246246
readonly value: vscode.TerminalShellExecution;
247247

248248
constructor(
249-
readonly terminal: vscode.Terminal,
250249
private _commandLine: vscode.TerminalShellExecutionCommandLine,
251250
readonly cwd: URI | undefined,
252251
) {
253252
const that = this;
254253
this.value = {
255-
get terminal(): vscode.Terminal {
256-
return that.terminal;
257-
},
258254
get commandLine(): vscode.TerminalShellExecutionCommandLine {
259255
return that._commandLine;
260256
},

src/vscode-dts/vscode.proposed.terminalShellIntegration.d.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ declare module 'vscode' {
1010
// TODO: Add missing docs
1111
// TODO: Review and polish up all docs
1212
export interface TerminalShellExecution {
13-
// TODO: Create a a `TerminalShellExecutionStartEvent` for future proofing and consistency with other events
14-
/**
15-
* The {@link Terminal} the command was executed in.
16-
*/
17-
readonly terminal: Terminal;
18-
1913
/**
2014
* The full command line that was executed, including both the command and arguments. The
2115
* {@link TerminalShellExecutionCommandLineConfidence confidence} of this value depends on
@@ -233,7 +227,34 @@ declare module 'vscode' {
233227
readonly shellIntegration: TerminalShellIntegration;
234228
}
235229

230+
export interface TerminalShellExecutionStartEvent {
231+
/**
232+
* The terminal that shell integration has been activated in.
233+
*/
234+
readonly terminal: Terminal;
235+
236+
/**
237+
* The shell integration object.
238+
*/
239+
readonly shellIntegration: TerminalShellIntegration;
240+
241+
/**
242+
* The terminal shell execution that has ended.
243+
*/
244+
readonly execution: TerminalShellExecution;
245+
}
246+
236247
export interface TerminalShellExecutionEndEvent {
248+
/**
249+
* The terminal that shell integration has been activated in.
250+
*/
251+
readonly terminal: Terminal;
252+
253+
/**
254+
* The shell integration object.
255+
*/
256+
readonly shellIntegration: TerminalShellIntegration;
257+
237258
/**
238259
* The terminal shell execution that has ended.
239260
*/
@@ -257,7 +278,7 @@ declare module 'vscode' {
257278
* [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) is
258279
* activated for the terminal.
259280
*/
260-
export const onDidStartTerminalShellExecution: Event<TerminalShellExecution>;
281+
export const onDidStartTerminalShellExecution: Event<TerminalShellExecutionStartEvent>;
261282

262283
/**
263284
* This will be fired when a terminal command is ended. This event will fire only when

0 commit comments

Comments
 (0)