include debug extension host env in shell env (#241078) (#298276)

* include debug extension host env in shell env (#241078)

* Use terminalEnvironment.mergeEnvironments for platform-specific considerations

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Clone the shell env to avoid mutation of a shared object

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Elie Richa
2026-03-02 16:04:43 +01:00
committed by GitHub
parent 41d62661ee
commit b9b33d2877

View File

@@ -37,6 +37,7 @@ import { IStatusbarService } from '../../../services/statusbar/browser/statusbar
import { memoize } from '../../../../base/common/decorators.js';
import { StopWatch } from '../../../../base/common/stopwatch.js';
import { IRemoteAgentService } from '../../../services/remote/common/remoteAgentService.js';
import { INativeWorkbenchEnvironmentService } from '../../../services/environment/electron-browser/environmentService.js';
import { shouldUseEnvironmentVariableCollection } from '../../../../platform/terminal/common/terminalEnvironment.js';
import { DisposableStore, MutableDisposable } from '../../../../base/common/lifecycle.js';
@@ -95,6 +96,7 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
@INativeHostService private readonly _nativeHostService: INativeHostService,
@IStatusbarService statusBarService: IStatusbarService,
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
@INativeWorkbenchEnvironmentService private readonly _environmentService: INativeWorkbenchEnvironmentService,
) {
super(_localPtyService, logService, historyService, _configurationResolverService, statusBarService, workspaceContextService);
@@ -294,7 +296,14 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
@memoize
async getShellEnvironment(): Promise<IProcessEnvironment> {
return this._shellEnvironmentService.getShellEnv();
const env = { ... await this._shellEnvironmentService.getShellEnv() };
// If running in the context of an extension development host, include the environment derived from the launch configuration
if (this._environmentService.debugExtensionHost.env) {
terminalEnvironment.mergeEnvironments(env, this._environmentService.debugExtensionHost.env);
}
return env;
}
async getWslPath(original: string, direction: 'unix-to-win' | 'win-to-unix'): Promise<string> {