提交 f0bd7eee 编写于 作者: M Megan Rogge

only create processEnvironment once, now tests pass

Co-authored by: Daniel Imms <daimms@microsoft.com>
上级 4300e6c7
......@@ -24,7 +24,7 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
import { Disposable } from 'vs/base/common/lifecycle';
import { withNullAsUndefined } from 'vs/base/common/types';
import { IEnvironmentVariableService, IMergedEnvironmentVariableCollection, IEnvironmentVariableInfo } from 'vs/workbench/contrib/terminal/common/environmentVariable';
import { EnvironmentVariableInfoStale, EnvironmentVariableInfoChangesActive } from 'vs/workbench/contrib/terminal/browser/environmentVariableInfo';
import { EnvironmentVariableInfoChangesActive, EnvironmentVariableInfoStale } from 'vs/workbench/contrib/terminal/browser/environmentVariableInfo';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { URI } from 'vs/base/common/uri';
......@@ -168,12 +168,8 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot();
<<<<<<< HEAD
// this is a copy of what the merged environment collection is on the remote side
await this._setupEnvVariableInfo(activeWorkspaceRootUri, shellLaunchConfig);
=======
await this._refreshEnvironmentVariables(activeWorkspaceRootUri, shellLaunchConfig);
>>>>>>> 60f1eac940 (Fix #105177 get terminal environment variable to show up in remote container)
const enableRemoteAgentTerminals = this._configHelper.config.serverSpawn;
if (enableRemoteAgentTerminals) {
......@@ -240,11 +236,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
}
// Fetch any extension environment additions and apply them
<<<<<<< HEAD
private async _setupEnvVariableInfo(activeWorkspaceRootUri: URI | undefined, shellLaunchConfig: IShellLaunchConfig): Promise<void> {
=======
private async _refreshEnvironmentVariables(activeWorkspaceRootUri: URI | undefined, shellLaunchConfig: IShellLaunchConfig): Promise<void> {
>>>>>>> 60f1eac940 (Fix #105177 get terminal environment variable to show up in remote container)
private async _setupEnvVariableInfo(activeWorkspaceRootUri: URI | undefined, shellLaunchConfig: IShellLaunchConfig): Promise<platform.IProcessEnvironment> {
const platformKey = platform.isWindows ? 'windows' : (platform.isMacintosh ? 'osx' : 'linux');
const lastActiveWorkspace = activeWorkspaceRootUri ? withNullAsUndefined(this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
const envFromConfigValue = this._workspaceConfigurationService.inspect<ITerminalEnvironment | undefined>(`terminal.integrated.env.${platformKey}`);
......@@ -256,21 +248,19 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
if (!shellLaunchConfig.strictEnv) {
this._extEnvironmentVariableCollection = this._environmentVariableService.mergedCollection;
this._register(this._environmentVariableService.onDidChangeCollections(newCollection => this._onEnvironmentVariableCollectionChange(newCollection)));
<<<<<<< HEAD
// For remote terminals, this is a copy of the mergedEnvironmentCollection created on
// the remote side. Since the environment collection is synced between the remote and
// local sides immediately this is a fairly safe way of enabling the env var diffing and
// info widget. While technically these could differ due to the slight change of a race
// condition, the chance is minimal plus the impact on the user is also not that great
// if it happens - it's not worth adding plumbing to sync back the resolved collection.
=======
>>>>>>> 60f1eac940 (Fix #105177 get terminal environment variable to show up in remote container)
this._extEnvironmentVariableCollection.applyToProcessEnvironment(env);
if (this._extEnvironmentVariableCollection.map.size > 0) {
this._environmentVariableInfo = new EnvironmentVariableInfoChangesActive(this._extEnvironmentVariableCollection);
this._onEnvironmentVariableInfoChange.fire(this._environmentVariableInfo);
}
}
return env;
}
private async _launchLocalProcess(
......@@ -310,17 +300,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
this._logService
);
const platformKey = platform.isWindows ? 'windows' : (platform.isMacintosh ? 'osx' : 'linux');
const envFromConfigValue = this._workspaceConfigurationService.inspect<ITerminalEnvironment | undefined>(`terminal.integrated.env.${platformKey}`);
const isWorkspaceShellAllowed = this._configHelper.checkWorkspaceShellPermissions();
const baseEnv = this._configHelper.config.inheritEnv ? processEnv : await this._terminalInstanceService.getMainProcessParentEnv();
const env = terminalEnvironment.createTerminalEnvironment(shellLaunchConfig, envFromConfigValue, terminalEnvironment.createVariableResolver(lastActiveWorkspace, this._configurationResolverService), isWorkspaceShellAllowed, this._productService.version, this._configHelper.config.detectLocale, baseEnv);
<<<<<<< HEAD
await this._setupEnvVariableInfo(activeWorkspaceRootUri, shellLaunchConfig);
=======
await this._refreshEnvironmentVariables(activeWorkspaceRootUri, shellLaunchConfig);
>>>>>>> 60f1eac940 (Fix #105177 get terminal environment variable to show up in remote container)
const env = await this._setupEnvVariableInfo(activeWorkspaceRootUri, shellLaunchConfig);
const useConpty = this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled;
return this._terminalInstanceService.createTerminalProcess(shellLaunchConfig, initialCwd, cols, rows, env, useConpty);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册