提交 ece3a90f 编写于 作者: D Daniel Imms

Tweak setLocaleVariables setting

- False now really means false
- The default is true for all platforms

Fixes #65037
上级 d236bfdd
......@@ -409,8 +409,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
// Continue env initialization, merging in the env from the launch
// config and adding keys that are needed to create the process
const locale = terminalConfig.get('setLocaleVariables') ? platform.locale : undefined;
terminalEnvironment.addTerminalEnvironmentKeys(env, locale);
terminalEnvironment.addTerminalEnvironmentKeys(env, platform.locale, terminalConfig.get('setLocaleVariables'));
// Fork the process and listen for messages
this._logService.debug(`Terminal process launching on ext host`, shellLaunchConfig, initialCwd, cols, rows, env);
......
......@@ -198,9 +198,9 @@ configurationRegistry.registerConfiguration({
default: 1000
},
'terminal.integrated.setLocaleVariables': {
markdownDescription: nls.localize('terminal.integrated.setLocaleVariables', "Controls whether locale variables are set at startup of the terminal, this defaults to `true` on macOS, `false` on other platforms."),
markdownDescription: nls.localize('terminal.integrated.setLocaleVariables', "Controls whether locale variables are set at startup of the terminal."),
type: 'boolean',
default: platform.isMacintosh
default: true
},
'terminal.integrated.rendererType': {
type: 'string',
......
......@@ -120,8 +120,7 @@ export class TerminalProcessManager implements ITerminalProcessManager {
terminalEnvironment.sanitizeEnvironment(env);
// Adding other env keys necessary to create the process
const locale = this._configHelper.config.setLocaleVariables ? platform.locale : undefined;
terminalEnvironment.addTerminalEnvironmentKeys(env, locale);
terminalEnvironment.addTerminalEnvironmentKeys(env, platform.locale, this._configHelper.config.setLocaleVariables);
this._logService.debug(`Terminal process launching`, shellLaunchConfig, this.initialCwd, cols, rows, env);
this._process = new TerminalProcess(shellLaunchConfig, this.initialCwd, cols, rows, env);
......
......@@ -76,10 +76,12 @@ export function sanitizeEnvironment(env: ITerminalEnvironment): void {
});
}
export function addTerminalEnvironmentKeys(env: ITerminalEnvironment, locale: string | undefined): void {
export function addTerminalEnvironmentKeys(env: ITerminalEnvironment, locale: string | undefined, setLocaleVariables: boolean): void {
env['TERM_PROGRAM'] = 'vscode';
env['TERM_PROGRAM_VERSION'] = pkg.version;
env['LANG'] = _getLangEnvVariable(locale);
if (setLocaleVariables) {
env['LANG'] = _getLangEnvVariable(locale);
}
}
export function resolveConfigurationVariables(configurationResolverService: IConfigurationResolverService, env: ITerminalEnvironment, lastActiveWorkspaceRoot: IWorkspaceFolder | null): ITerminalEnvironment {
......
......@@ -14,18 +14,22 @@ suite('Workbench - TerminalEnvironment', () => {
test('addTerminalEnvironmentKeys', () => {
const env = { FOO: 'bar' };
const locale = 'en-au';
terminalEnvironment.addTerminalEnvironmentKeys(env, locale);
terminalEnvironment.addTerminalEnvironmentKeys(env, locale, true);
assert.equal(env['TERM_PROGRAM'], 'vscode');
assert.equal(env['TERM_PROGRAM_VERSION'].search(/^\d+\.\d+\.\d+$/), 0);
assert.equal(env['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
const env2 = { FOO: 'bar' };
terminalEnvironment.addTerminalEnvironmentKeys(env2, null);
terminalEnvironment.addTerminalEnvironmentKeys(env2, undefined, true);
assert.equal(env2['LANG'], 'en_US.UTF-8', 'LANG is equal to en_US.UTF-8 as fallback.'); // More info on issue #14586
const env3 = { LANG: 'en_US.UTF-8' };
terminalEnvironment.addTerminalEnvironmentKeys(env3, null);
assert.equal(env3['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');
const env3 = { LANG: 'replace' };
terminalEnvironment.addTerminalEnvironmentKeys(env3, undefined, true);
assert.equal(env3['LANG'], 'en_US.UTF-8', 'LANG is set to the fallback LANG');
const env4 = { LANG: 'en_US.UTF-8' };
terminalEnvironment.addTerminalEnvironmentKeys(env3, undefined, true);
assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');
});
test('sanitizeEnvironment', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册