Skip to content

Commit 484d161

Browse files
committed
Only light up .shellIntegration API if it has rich command detection
Part of microsoft#242897
1 parent 79e31e7 commit 484d161

File tree

5 files changed

+4
-58
lines changed

5 files changed

+4
-58
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,6 @@ const _allApiProposals = {
361361
terminalShellEnv: {
362362
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalShellEnv.d.ts',
363363
},
364-
terminalShellIntegrationRich: {
365-
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalShellIntegrationRich.d.ts',
366-
},
367364
terminalShellType: {
368365
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalShellType.d.ts',
369366
},

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,20 @@ export class MainThreadTerminalShellIntegration extends Disposable implements Ma
3636
// onDidChangeTerminalShellIntegration initial state
3737
for (const terminal of this._terminalService.instances) {
3838
const cmdDetection = terminal.capabilities.get(TerminalCapability.CommandDetection);
39-
if (cmdDetection) {
39+
if (cmdDetection?.hasRichCommandDetection) {
4040
this._proxy.$shellIntegrationChange(terminal.instanceId);
41-
this._proxy.$setHasRichCommandDetection(terminal.instanceId, !!cmdDetection?.hasRichCommandDetection);
4241
}
4342
const cwdDetection = terminal.capabilities.get(TerminalCapability.CwdDetection);
4443
if (cwdDetection) {
4544
this._proxy.$cwdChange(terminal.instanceId, this._convertCwdToUri(cwdDetection.getCwd()));
4645
}
4746
}
4847

49-
// onDidChangeTerminalShellIntegration via command detection
50-
const onDidAddCommandDetection = this._store.add(this._terminalService.createOnInstanceEvent(instance => {
51-
return Event.map(
52-
Event.filter(instance.capabilities.onDidAddCapabilityType, e => {
53-
return (e === TerminalCapability.CwdDetection || e === TerminalCapability.CommandDetection);
54-
}),
55-
() => instance
56-
);
57-
})).event;
58-
this._store.add(onDidAddCommandDetection(e => this._proxy.$shellIntegrationChange(e.instanceId)));
59-
6048
// onDidChangeTerminalShellIntegration via rich command detection
6149
const onDidSetRichCommandDetection = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CommandDetection, e => e.onSetRichCommandDetection));
62-
onDidSetRichCommandDetection.event(e => {
63-
this._proxy.$setHasRichCommandDetection(e.instance.instanceId, e.data);
64-
});
50+
this._store.add(onDidSetRichCommandDetection.event(e => {
51+
this._proxy.$shellIntegrationChange(e.instance.instanceId);
52+
}));
6553

6654
// onDidChangeTerminalShellIntegration via cwd
6755
const cwdChangeEvent = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CwdDetection, e => e.onDidChangeCwd));

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,6 @@ export interface ExtHostTerminalShellIntegrationShape {
25252525
$shellExecutionData(instanceId: number, data: string): void;
25262526
$shellEnvChange(instanceId: number, shellEnvKeys: string[], shellEnvValues: string[], isTrusted: boolean): void;
25272527
$cwdChange(instanceId: number, cwd: UriComponents | undefined): void;
2528-
$setHasRichCommandDetection(instanceId: number, value: boolean): void;
25292528
$closeTerminal(instanceId: number): void;
25302529
}
25312530

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ export class ExtHostTerminalShellIntegration extends Disposable implements IExtH
143143
this._activeShellIntegrations.get(instanceId)?.dispose();
144144
this._activeShellIntegrations.delete(instanceId);
145145
}
146-
147-
public $setHasRichCommandDetection(instanceId: number, value: boolean): void {
148-
this._activeShellIntegrations.get(instanceId)?.setHasRichCommandDetection(value);
149-
}
150146
}
151147

152148
interface IExecutionProperties {
@@ -165,7 +161,6 @@ export class InternalTerminalShellIntegration extends Disposable {
165161

166162
private _env: vscode.TerminalShellIntegrationEnvironment | undefined;
167163
private _cwd: URI | undefined;
168-
private _hasRichCommandDetection: boolean = false;
169164

170165
readonly store: DisposableStore = this._register(new DisposableStore());
171166

@@ -200,9 +195,6 @@ export class InternalTerminalShellIntegration extends Disposable {
200195
value: Object.freeze({ ...that._env.value })
201196
});
202197
},
203-
get hasRichCommandDetection(): boolean {
204-
return that._hasRichCommandDetection;
205-
},
206198
// executeCommand(commandLine: string): vscode.TerminalShellExecution;
207199
// executeCommand(executable: string, args: string[]): vscode.TerminalShellExecution;
208200
executeCommand(commandLineOrExecutable: string, args?: string[]): vscode.TerminalShellExecution {
@@ -264,9 +256,6 @@ export class InternalTerminalShellIntegration extends Disposable {
264256
return;
265257
}
266258
}
267-
if (this._hasRichCommandDetection) {
268-
console.warn('Rich command detection is enabled but an execution started before the last ended');
269-
}
270259
this._currentExecution.endExecution(undefined);
271260
this._currentExecution.flush();
272261
this._onDidRequestEndExecution.fire({ terminal: this._terminal, shellIntegration: this.value, execution: this._currentExecution.value, exitCode: undefined });
@@ -345,13 +334,6 @@ export class InternalTerminalShellIntegration extends Disposable {
345334
}
346335
}
347336

348-
setHasRichCommandDetection(value: boolean): void {
349-
if (this._hasRichCommandDetection !== value) {
350-
this._hasRichCommandDetection = value;
351-
this._fireChangeEvent();
352-
}
353-
}
354-
355337
setEnv(keys: string[], values: string[], isTrusted: boolean): void {
356338
const env: { [key: string]: string | undefined } = {};
357339
for (let i = 0; i < keys.length; i++) {

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

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)