Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onDidChangeShell event to the API #160900

Merged
merged 9 commits into from Sep 14, 2022
3 changes: 3 additions & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Expand Up @@ -309,6 +309,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
get shell() {
return extHostTerminalService.getDefaultShell(false);
},
get onDidChangeShell() {
return extHostTerminalService.onDidChangeShell;
Tyriar marked this conversation as resolved.
Show resolved Hide resolved
},
get isTelemetryEnabled() {
return extHostTelemetry.getTelemetryConfiguration();
},
Expand Down
7 changes: 7 additions & 0 deletions src/vs/workbench/api/common/extHostTerminalService.ts
Expand Up @@ -37,6 +37,7 @@ export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, ID
onDidChangeTerminalDimensions: Event<vscode.TerminalDimensionsChangeEvent>;
onDidChangeTerminalState: Event<vscode.Terminal>;
onDidWriteTerminalData: Event<vscode.TerminalDataWriteEvent>;
onDidChangeShell: Event<string>;

createTerminal(name?: string, shellPath?: string, shellArgs?: readonly string[] | string): vscode.Terminal;
createTerminalFromOptions(options: vscode.TerminalOptions, internalOptions?: ITerminalInternalOptions): vscode.Terminal;
Expand Down Expand Up @@ -376,6 +377,8 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
readonly onDidChangeTerminalState = this._onDidChangeTerminalState.event;
protected readonly _onDidWriteTerminalData: Emitter<vscode.TerminalDataWriteEvent>;
get onDidWriteTerminalData(): Event<vscode.TerminalDataWriteEvent> { return this._onDidWriteTerminalData.event; }
protected readonly _onDidChangeShell: Emitter<string> = new Emitter();
get onDidChangeShell(): Event<string> { return this._onDidChangeShell.event; }

constructor(
supportsProcesses: boolean,
Expand Down Expand Up @@ -809,8 +812,12 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
}

public $acceptDefaultProfile(profile: ITerminalProfile, automationProfile: ITerminalProfile): void {
const oldProfile = this._defaultProfile;
Tyriar marked this conversation as resolved.
Show resolved Hide resolved
this._defaultProfile = profile;
this._defaultAutomationProfile = automationProfile;
if (oldProfile?.path !== profile.path) {
this._onDidChangeShell.fire(profile.path);
}
}

private _setEnvironmentVariableCollection(extensionIdentifier: string, collection: EnvironmentVariableCollection): void {
Expand Down
16 changes: 16 additions & 0 deletions 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<string>;
}
}