From d336c5cd1e09f922aa8495a0a5a1030b9bacd81f Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 13:33:58 +0000 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=8E=81=20Add=20`onDidChangeShell`=20e?= =?UTF-8?q?vent=20to=20ext=20host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Babak K. Shandiz --- src/vs/workbench/api/common/extHost.api.impl.ts | 3 +++ src/vs/workbench/api/common/extHostTerminalService.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 708b4db0c46..cd6e15cbed9 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -309,6 +309,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I get shell() { return extHostTerminalService.getDefaultShell(false); }, + get onDidChangeShell() { + 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 0f5ebe088fb..8f3e55bc7ec 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -37,6 +37,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; @@ -376,6 +377,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: Emitter = new Emitter(); + get onDidChangeShell(): Event { return this._onDidChangeShell.event; } constructor( supportsProcesses: boolean, @@ -809,8 +812,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 || oldProfile.path !== profile.path) { + this._onDidChangeShell.fire(profile.path); + } } private _setEnvironmentVariableCollection(extensionIdentifier: string, collection: EnvironmentVariableCollection): void { From 1fb1087ab3d6513e1da31e6a1b4b7bfecc1b0522 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 13:35:52 +0000 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=94=A8=20Add=20`onDidShellChange`=20t?= =?UTF-8?q?o=20the=20API=20definitions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Babak K. Shandiz --- src/vscode-dts/vscode.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index 2c90006429d..5bd3167e0f0 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -9178,6 +9178,11 @@ declare module 'vscode' { */ export const shell: string; + /** + * An {@link Event} which fires when the default shell changes. + */ + export const onDidChangeShell: Event; + /** * The UI kind property indicates from which UI extensions * are accessed from. For example, extensions could be accessed From 81a0d8439e6ccb199ee051b06a770966225ec1fe Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 18:17:47 +0430 Subject: [PATCH 3/9] Update src/vs/workbench/api/common/extHostTerminalService.ts Co-authored-by: Daniel Imms <2193314+Tyriar@users.noreply.github.com> --- src/vs/workbench/api/common/extHostTerminalService.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index 8f3e55bc7ec..ad74052f1a8 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -812,10 +812,9 @@ 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 || oldProfile.path !== profile.path) { + if (oldProfile?.path !== profile.path) { this._onDidChangeShell.fire(profile.path); } } From 687d52435816c51e66a9bbf10f2c0556f697d5e0 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 18:23:05 +0430 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=94=A8=20Move=20new=20definition=20in?= =?UTF-8?q?to=20a=20proposed=20`.d.ts`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Babak K. Shandiz --- src/vscode-dts/vscode.d.ts | 5 ----- .../vscode.proposed.envShellEvent.d.ts | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 src/vscode-dts/vscode.proposed.envShellEvent.d.ts diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index 5bd3167e0f0..2c90006429d 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -9178,11 +9178,6 @@ declare module 'vscode' { */ export const shell: string; - /** - * An {@link Event} which fires when the default shell changes. - */ - export const onDidChangeShell: Event; - /** * The UI kind property indicates from which UI extensions * are accessed from. For example, extensions could be accessed 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; + } +} From 3e9188f299055db6a6cf2bf9984da3e05df434b0 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 18:26:50 +0430 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=90=9B=20Fix=20missing=20variable=20d?= =?UTF-8?q?efinition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Babak K. Shandiz --- src/vs/workbench/api/common/extHostTerminalService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index ad74052f1a8..725945f7538 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -812,6 +812,7 @@ 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) { From d4a73d492bb706269840a29258982b5e2b8738a8 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 18:45:40 +0430 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=94=A8=20Add=20`envShellEvent`=20to?= =?UTF-8?q?=20API=20proposals=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Babak K. Shandiz --- .../services/extensions/common/extensionsApiProposals.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 2754bd2327d..10642e1c824 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', From 9b11b34bf1b4c2c1e484500a2b454fd2be8dd390 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 18:46:56 +0430 Subject: [PATCH 7/9] =?UTF-8?q?=F0=9F=95=B5=20Check=20extension=20has=20en?= =?UTF-8?q?abled=20`envShellEvent`=20proposed=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Babak K. Shandiz --- src/vs/workbench/api/common/extHost.api.impl.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index cd6e15cbed9..66dc4868670 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -310,6 +310,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostTerminalService.getDefaultShell(false); }, get onDidChangeShell() { + checkProposedApiEnabled(extension, 'envShellEvent'); return extHostTerminalService.onDidChangeShell; }, get isTelemetryEnabled() { From fca8afcb170571318cbe6892e946ef015092323e Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Wed, 14 Sep 2022 18:48:40 +0430 Subject: [PATCH 8/9] =?UTF-8?q?=F0=9F=92=84=20Improve=20style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Babak K. Shandiz --- src/vs/workbench/api/common/extHostTerminalService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index 725945f7538..fbfce1e4630 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -377,8 +377,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: Emitter = new Emitter(); - get onDidChangeShell(): Event { return this._onDidChangeShell.event; } + protected readonly _onDidChangeShell = new Emitter(); + readonly onDidChangeShell = this._onDidChangeShell.event; constructor( supportsProcesses: boolean, From c4611298a385cd36792b7752084cc7de1017d4c2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 14 Sep 2022 07:32:41 -0700 Subject: [PATCH 9/9] Add envShellEvent to vscode-api-tests --- extensions/vscode-api-tests/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode-api-tests/package.json b/extensions/vscode-api-tests/package.json index 54c7463d9a0..9211f0c21f5 100644 --- a/extensions/vscode-api-tests/package.json +++ b/extensions/vscode-api-tests/package.json @@ -37,6 +37,7 @@ "taskPresentationGroup", "terminalDataWriteEvent", "terminalDimensions", + "envShellEvent", "testCoverage", "testObserver", "textSearchProvider",