Skip to content

Commit 45d2bb4

Browse files
committed
Docs, simplify ext host protocol
1 parent fe4617d commit 45d2bb4

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

src/vs/workbench/api/browser/mainThreadTerminalShellIntegration.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ export class MainThreadTerminalShellIntegration extends Disposable implements Ma
3030
}, this._store), () => instance
3131
);
3232
});
33-
this._store.add(onDidAddCommandDetection(e => this._proxy.$acceptDidChangeShellIntegration(e.instanceId)));
33+
this._store.add(onDidAddCommandDetection(e => this._proxy.$shellIntegrationChange(e.instanceId)));
3434

3535
// onDidStartTerminalShellExecution
3636
const commandDetectionStartEvent = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CommandDetection, e => e.onCommandExecuted));
37-
this._store.add(commandDetectionStartEvent.event(e => this._proxy.$acceptTerminalShellExecutionStart(e.instance.instanceId, e.data.command, e.data.cwd)));
37+
this._store.add(commandDetectionStartEvent.event(e => this._proxy.$shellExecutionStart(e.instance.instanceId, e.data.command, e.data.cwd)));
3838

3939
// onDidEndTerminalShellExecution
4040
const commandDetectionEndEvent = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CommandDetection, e => e.onCommandFinished));
41-
this._store.add(commandDetectionEndEvent.event(e => this._proxy.$acceptTerminalShellExecutionEnd(e.instance.instanceId, e.data.command, e.data.exitCode)));
41+
this._store.add(commandDetectionEndEvent.event(e => this._proxy.$shellExecutionEnd(e.instance.instanceId, e.data.command, e.data.exitCode)));
4242

4343
// onDidChangeTerminalShellIntegration via cwd
4444
const cwdChangeEvent = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CwdDetection, e => e.onDidChangeCwd));
45-
this._store.add(cwdChangeEvent.event(e => this._proxy.$acceptTerminalCwdChange(e.instance.instanceId, e.data)));
45+
this._store.add(cwdChangeEvent.event(e => this._proxy.$cwdChange(e.instance.instanceId, e.data)));
4646

4747
// Clean up after dispose
48-
this._store.add(this._terminalService.onDidDisposeInstance(e => this._proxy.$acceptCloseTerminal(e.instanceId)));
48+
this._store.add(this._terminalService.onDidDisposeInstance(e => this._proxy.$closeTerminal(e.instanceId)));
4949

5050
// TODO: Only do this if there is a consumer
5151
// TODO: This needs to go via the server on remote for performance reasons
5252
// TerminalShellExecution.dataStream
53-
this._store.add(this._terminalService.onAnyInstanceData(e => this._proxy.$acceptTerminalShellExecutionData(e.instance.instanceId, e.data)));
53+
this._store.add(this._terminalService.onAnyInstanceData(e => this._proxy.$shellExecutionData(e.instance.instanceId, e.data)));
5454
}
5555

5656
$executeCommand(terminalId: number, commandLine: string): void {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,12 +2267,12 @@ export interface ExtHostTerminalServiceShape {
22672267
}
22682268

22692269
export interface ExtHostTerminalShellIntegrationShape {
2270-
$acceptDidChangeShellIntegration(instanceId: number): void;
2271-
$acceptTerminalShellExecutionStart(instanceId: number, commandLine: string | undefined, cwd: UriComponents | string | undefined): void;
2272-
$acceptTerminalShellExecutionEnd(instanceId: number, commandLine: string | undefined, exitCode: number | undefined): void;
2273-
$acceptTerminalShellExecutionData(instanceId: number, data: string): void;
2274-
$acceptTerminalCwdChange(instanceId: number, cwd: UriComponents | string): void;
2275-
$acceptCloseTerminal(instanceId: number): void;
2270+
$shellIntegrationChange(instanceId: number): void;
2271+
$shellExecutionStart(instanceId: number, commandLine: string | undefined, cwd: UriComponents | string | undefined): void;
2272+
$shellExecutionEnd(instanceId: number, commandLine: string | undefined, exitCode: number | undefined): void;
2273+
$shellExecutionData(instanceId: number, data: string): void;
2274+
$cwdChange(instanceId: number, cwd: UriComponents | string): void;
2275+
$closeTerminal(instanceId: number): void;
22762276
}
22772277

22782278
export interface ExtHostSCMShape {

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

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,32 @@ export class ExtHostTerminalShellIntegration extends Disposable implements IExtH
5353
this._activeShellIntegrations.clear();
5454
}));
5555

56-
// TODO: Remove test code
57-
this.onDidChangeTerminalShellIntegration(e => {
58-
console.log('*** onDidChangeTerminalShellIntegration', e);
59-
});
60-
this.onDidStartTerminalShellExecution(async e => {
61-
console.log('*** onDidStartTerminalShellExecution', e);
62-
// new Promise<void>(r => {
63-
// (async () => {
64-
// for await (const d of e.createDataStream()) {
65-
// console.log('data2', d);
66-
// }
67-
// })();
68-
// });
69-
for await (const d of e.createDataStream()) {
70-
console.log('data', d);
71-
}
72-
});
73-
this.onDidEndTerminalShellExecution(e => {
74-
console.log('*** onDidEndTerminalShellExecution', e);
75-
});
76-
77-
setTimeout(() => {
78-
Array.from(this._activeShellIntegrations.values())[0].value.executeCommand('echo hello');
79-
}, 4000);
56+
// Convenient test code:
57+
// this.onDidChangeTerminalShellIntegration(e => {
58+
// console.log('*** onDidChangeTerminalShellIntegration', e);
59+
// });
60+
// this.onDidStartTerminalShellExecution(async e => {
61+
// console.log('*** onDidStartTerminalShellExecution', e);
62+
// // new Promise<void>(r => {
63+
// // (async () => {
64+
// // for await (const d of e.createDataStream()) {
65+
// // console.log('data2', d);
66+
// // }
67+
// // })();
68+
// // });
69+
// for await (const d of e.createDataStream()) {
70+
// console.log('data', d);
71+
// }
72+
// });
73+
// this.onDidEndTerminalShellExecution(e => {
74+
// console.log('*** onDidEndTerminalShellExecution', e);
75+
// });
76+
// setTimeout(() => {
77+
// Array.from(this._activeShellIntegrations.values())[0].value.executeCommand('echo hello');
78+
// }, 4000);
8079
}
8180

82-
public $acceptDidChangeShellIntegration(instanceId: number): void {
81+
public $shellIntegrationChange(instanceId: number): void {
8382
const terminal = this._extHostTerminalService.getTerminalById(instanceId);
8483
if (!terminal) {
8584
return;
@@ -104,28 +103,28 @@ export class ExtHostTerminalShellIntegration extends Disposable implements IExtH
104103
});
105104
}
106105

107-
public $acceptTerminalShellExecutionStart(instanceId: number, commandLine: string, cwd: URI | string | undefined): void {
106+
public $shellExecutionStart(instanceId: number, commandLine: string, cwd: URI | string | undefined): void {
108107
// Force shellIntegration creation if it hasn't been created yet, this could when events
109108
// don't come through on startup
110109
if (!this._activeShellIntegrations.has(instanceId)) {
111-
this.$acceptDidChangeShellIntegration(instanceId);
110+
this.$shellIntegrationChange(instanceId);
112111
}
113112
this._activeShellIntegrations.get(instanceId)?.startShellExecution(commandLine, cwd);
114113
}
115114

116-
public $acceptTerminalShellExecutionEnd(instanceId: number, commandLine: string | undefined, exitCode: number | undefined): void {
115+
public $shellExecutionEnd(instanceId: number, commandLine: string | undefined, exitCode: number | undefined): void {
117116
this._activeShellIntegrations.get(instanceId)?.endShellExecution(commandLine, exitCode);
118117
}
119118

120-
public $acceptTerminalShellExecutionData(instanceId: number, data: string): void {
119+
public $shellExecutionData(instanceId: number, data: string): void {
121120
this._activeShellIntegrations.get(instanceId)?.emitData(data);
122121
}
123122

124-
public $acceptTerminalCwdChange(instanceId: number, cwd: string): void {
123+
public $cwdChange(instanceId: number, cwd: string): void {
125124
this._activeShellIntegrations.get(instanceId)?.setCwd(cwd);
126125
}
127126

128-
public $acceptCloseTerminal(instanceId: number): void {
127+
public $closeTerminal(instanceId: number): void {
129128
this._activeShellIntegrations.get(instanceId)?.dispose();
130129
this._activeShellIntegrations.delete(instanceId);
131130

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ declare module 'vscode' {
3131
/**
3232
* The working directory that was reported by the shell when this command executed. This
3333
* will be a {@link Uri} if the string reported by the shell can reliably be mapped to the
34-
* connected machine.
34+
* connected machine. This requires the shell integration to support working directory
35+
* reporting via the [`OSC 633 ; P`](https://code.visualstudio.com/docs/terminal/shell-integration#_vs-code-custom-sequences-osc-633-st)
36+
* or `OSC 1337 ; CurrentDir=<Cwd> ST` sequences.
3537
*/
3638
cwd: Uri | string | undefined;
3739

@@ -69,7 +71,6 @@ declare module 'vscode' {
6971

7072
export interface TerminalShellIntegration {
7173
// TODO: Is this fine to share the TerminalShellIntegrationChangeEvent event?
72-
// TODO: Should we have TerminalShellExecution.cwd if this exists?
7374
/**
7475
* The current working directory of the terminal. This will be a {@link Uri} if the string
7576
* reported by the shell can reliably be mapped to the connected machine.

0 commit comments

Comments
 (0)