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

Run configurationResolver on terminal env vars #40059

Merged
merged 5 commits into from
Dec 12, 2017

Conversation

ramya-rao-a
Copy link
Contributor

@ramya-rao-a ramya-rao-a commented Dec 11, 2017

Fixes #34337

@ramya-rao-a ramya-rao-a requested a review from Tyriar December 11, 2017 23:55
@ramya-rao-a ramya-rao-a self-assigned this Dec 11, 2017
// Merge process env with the env from config
const envFromConfig = { ...process.env };
const lastActiveWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot('file');
const lastActiveWorkspaceRoot = this._workspaceContextService.getWorkspaceFolder(lastActiveWorkspaceRootUri);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this variable down to the other chunk to make it clear that it's not used in the following line.

const envSettingKey = platform.isWindows ? 'windows' : (platform.isMacintosh ? 'osx' : 'linux');
TerminalInstance.mergeEnvironments(envFromConfig, this._configHelper.config.env[envSettingKey]);
const envFromConfig = { ...this._configHelper.config.env[envSettingKey] };
Object.keys(envFromConfig).forEach((key) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section's getting a bit crazy, how about we organize it like this:

  • mergeEnvironments now takes a base environment and an array of secondary environments
  • The secondary environments are filtered through a resolveConfigurationVariables

I think we could then minimize the number of lines dealing with the env in this function and de-duplicate the _configurationResolverService parts. What do you think?

Copy link
Contributor Author

@ramya-rao-a ramya-rao-a Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought exactly that about the mergeEnvironments. But, one issue with that though is that mergeEnvironments is static. Resolving of variables need the configurationResolverService and the workspaceRoot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If changing the static is too much work then you can pass in _configurationResolveService as a param.

@Tyriar Tyriar added this to the December 2017 milestone Dec 12, 2017
// TODO: locale should not be optional
public static createTerminalEnv(parentEnv: IStringDictionary<string>, shell: IShellLaunchConfig, cwd: string, locale?: string, cols?: number, rows?: number): IStringDictionary<string> {
protected createTerminalEnv(parentEnv: IStringDictionary<string>, shell: IShellLaunchConfig, cwd: string, locale?: string, cols?: number, rows?: number): IStringDictionary<string> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar How about making createTerminalEnv non static?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for that, the only reason it's still like that is because the tests were written that way. It would be better to do protected and inherit in a super testing class. You would probably have to block out the terminal process launching stuff from launching during tests for that to work though which might be too much work for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I'll revert that change

@ramya-rao-a ramya-rao-a force-pushed the resolve-terminal-env-vars branch from 9b441c4 to 2e4a98b Compare December 12, 2017 01:50
@Tyriar
Copy link
Member

Tyriar commented Dec 12, 2017

Moved the variable resolving into its own function and tested, looks good 👌

image

@Tyriar
Copy link
Member

Tyriar commented Dec 12, 2017

Good to merge after CI passes

@ramya-rao-a ramya-rao-a merged commit 43db454 into master Dec 12, 2017
@ramya-rao-a ramya-rao-a deleted the resolve-terminal-env-vars branch December 12, 2017 19:15
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve standard VS Code variables in "terminal.integrated.env.*"
2 participants