diff --git a/extensions/vscode-api-tests/package.json b/extensions/vscode-api-tests/package.json index ef88695c825..3c4c9a5bc30 100644 --- a/extensions/vscode-api-tests/package.json +++ b/extensions/vscode-api-tests/package.json @@ -36,6 +36,7 @@ "taskPresentationGroup", "terminalDataWriteEvent", "terminalDimensions", + "envShellEvent", "testCoverage", "testObserver", "textSearchProvider", diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 3de62a38d34..8fadafd3118 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -309,6 +309,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I get shell() { return extHostTerminalService.getDefaultShell(false); }, + get onDidChangeShell() { + checkProposedApiEnabled(extension, 'envShellEvent'); + return extHostTerminalService.onDidChangeShell; + }, get isTelemetryEnabled() { return extHostTelemetry.getTelemetryConfiguration(); }, diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index 22dd7d190ad..4e94afddd1a 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -39,6 +39,7 @@ export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, ID onDidChangeTerminalDimensions: Event; onDidChangeTerminalState: Event; onDidWriteTerminalData: Event; + onDidChangeShell: Event; createTerminal(name?: string, shellPath?: string, shellArgs?: readonly string[] | string): vscode.Terminal; createTerminalFromOptions(options: vscode.TerminalOptions, internalOptions?: ITerminalInternalOptions): vscode.Terminal; @@ -378,6 +379,8 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I readonly onDidChangeTerminalState = this._onDidChangeTerminalState.event; protected readonly _onDidWriteTerminalData: Emitter; get onDidWriteTerminalData(): Event { return this._onDidWriteTerminalData.event; } + protected readonly _onDidChangeShell = new Emitter(); + readonly onDidChangeShell = this._onDidChangeShell.event; constructor( supportsProcesses: boolean, @@ -811,8 +814,12 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I } public $acceptDefaultProfile(profile: ITerminalProfile, automationProfile: ITerminalProfile): void { + const oldProfile = this._defaultProfile; this._defaultProfile = profile; this._defaultAutomationProfile = automationProfile; + if (oldProfile?.path !== profile.path) { + this._onDidChangeShell.fire(profile.path); + } } private _setEnvironmentVariableCollection(extensionIdentifier: string, collection: EnvironmentVariableCollection): void { diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 3c8446b2b12..6d0b33157b9 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -25,6 +25,7 @@ export const allApiProposals = Object.freeze({ documentPaste: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.documentPaste.d.ts', editSessionIdentityProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.editSessionIdentityProvider.d.ts', editorInsets: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.editorInsets.d.ts', + envShellEvent: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.envShellEvent.d.ts', extensionRuntime: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.extensionRuntime.d.ts', extensionsAny: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.extensionsAny.d.ts', externalUriOpener: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.externalUriOpener.d.ts', diff --git a/src/vscode-dts/vscode.proposed.envShellEvent.d.ts b/src/vscode-dts/vscode.proposed.envShellEvent.d.ts new file mode 100644 index 00000000000..8fed971ef71 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.envShellEvent.d.ts @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + // See https://github.com/microsoft/vscode/issues/160694 + export namespace env { + + /** + * An {@link Event} which fires when the default shell changes. + */ + export const onDidChangeShell: Event; + } +}