move to IProcessEnvService where appropriate in default shell logic (#118271)
* move to IProcessEnvService where appropriate * change distro
This commit is contained in:
parent
ac229ced07
commit
27975dad4f
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "code-oss-dev",
|
||||
"version": "1.55.0",
|
||||
"distro": "0357427beb5cd348177cd1ed381cd740082966c4",
|
||||
"distro": "01f21bd70c49582992ba219c57b78d1c94bb5da7",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
|
|
|
@ -13,7 +13,7 @@ import * as processes from 'vs/base/node/processes';
|
|||
* shell that the terminal uses by default.
|
||||
* @param p The platform to detect the shell of.
|
||||
*/
|
||||
export async function getSystemShell(p: platform.Platform, env = process.env as platform.IProcessEnvironment): Promise<string> {
|
||||
export async function getSystemShell(p: platform.Platform, env: platform.IProcessEnvironment): Promise<string> {
|
||||
if (p === platform.Platform.Windows) {
|
||||
if (platform.isWindows) {
|
||||
return getSystemShellWindows();
|
||||
|
@ -25,7 +25,7 @@ export async function getSystemShell(p: platform.Platform, env = process.env as
|
|||
return getSystemShellUnixLike(p, env);
|
||||
}
|
||||
|
||||
export function getSystemShellSync(p: platform.Platform, env = process.env as platform.IProcessEnvironment): string {
|
||||
export function getSystemShellSync(p: platform.Platform, env: platform.IProcessEnvironment): string {
|
||||
if (p === platform.Platform.Windows) {
|
||||
if (platform.isWindows) {
|
||||
return getSystemShellWindowsSync(env);
|
||||
|
|
|
@ -79,7 +79,7 @@ async function doResolveUnixShellEnv(logService: ILogService): Promise<typeof pr
|
|||
logService.trace('getUnixShellEnvironment#env', env);
|
||||
logService.trace('getUnixShellEnvironment#spawn', command);
|
||||
|
||||
const systemShellUnix = await getSystemShell(platform);
|
||||
const systemShellUnix = await getSystemShell(platform, env);
|
||||
const child = spawn(systemShellUnix, ['-ilc', command], {
|
||||
detached: true,
|
||||
stdio: ['ignore', 'pipe', process.stderr],
|
||||
|
|
|
@ -41,7 +41,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
|
|||
// Getting the SystemShell is an async operation, however, the ExtHost terminal service is mostly synchronous
|
||||
// and the API `vscode.env.shell` is also synchronous. The default shell _should_ be set when extensions are
|
||||
// starting up but if not, we run getSystemShellSync below which gets a sane default.
|
||||
getSystemShell(platform.platform).then(s => this._defaultShell = s);
|
||||
getSystemShell(platform.platform, process.env as platform.IProcessEnvironment).then(s => this._defaultShell = s);
|
||||
|
||||
this._updateLastActiveWorkspace();
|
||||
this._updateVariableResolver();
|
||||
|
@ -83,7 +83,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
|
|||
return terminalEnvironment.getDefaultShell(
|
||||
fetchSetting,
|
||||
this._isWorkspaceShellAllowed,
|
||||
this._defaultShell ?? getSystemShellSync(platform.platform),
|
||||
this._defaultShell ?? getSystemShellSync(platform.platform, process.env as platform.IProcessEnvironment),
|
||||
process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'),
|
||||
process.env.windir,
|
||||
terminalEnvironment.createVariableResolver(this._lastActiveWorkspace, this._variableResolver),
|
||||
|
|
|
@ -13,6 +13,8 @@ import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/co
|
|||
import { getTerminalShellConfiguration } from 'vs/workbench/contrib/terminal/common/terminalConfiguration';
|
||||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { getSystemShell } from 'vs/base/node/shell';
|
||||
import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
|
||||
import { Platform } from 'vs/base/common/platform';
|
||||
|
||||
// This file contains additional desktop-only contributions on top of those in browser/
|
||||
|
||||
|
@ -25,4 +27,5 @@ workbenchRegistry.registerWorkbenchContribution(TerminalNativeContribution, Life
|
|||
// Register configurations
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
|
||||
|
||||
getTerminalShellConfiguration(getSystemShell).then(config => configurationRegistry.registerConfiguration(config));
|
||||
const systemShell = async (p: Platform) => getSystemShell(p, await process.getShellEnv());
|
||||
getTerminalShellConfiguration(systemShell).then(config => configurationRegistry.registerConfiguration(config));
|
||||
|
|
|
@ -13,6 +13,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
|
|||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { getMainProcessParentEnv } from 'vs/workbench/contrib/terminal/node/terminalEnvironment';
|
||||
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
|
||||
import { IShellEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/shellEnvironmentService';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import type { Terminal as XTermTerminal } from 'xterm';
|
||||
import type { SearchAddon as XTermSearchAddon } from 'xterm-addon-search';
|
||||
|
@ -34,7 +35,8 @@ export class TerminalInstanceService extends Disposable implements ITerminalInst
|
|||
@IConfigurationResolverService private readonly _configurationResolverService: IConfigurationResolverService,
|
||||
@IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService,
|
||||
@IHistoryService private readonly _historyService: IHistoryService,
|
||||
@ILogService private readonly _logService: ILogService
|
||||
@ILogService private readonly _logService: ILogService,
|
||||
@IShellEnvironmentService private readonly _shellEnvironmentService: IShellEnvironmentService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
@ -76,10 +78,11 @@ export class TerminalInstanceService extends Disposable implements ITerminalInst
|
|||
const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot();
|
||||
let lastActiveWorkspace = activeWorkspaceRootUri ? this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri) : undefined;
|
||||
lastActiveWorkspace = lastActiveWorkspace === null ? undefined : lastActiveWorkspace;
|
||||
|
||||
const shell = getDefaultShell(
|
||||
(key) => this._configurationService.inspect(key),
|
||||
isWorkspaceShellAllowed,
|
||||
await getSystemShell(platformOverride),
|
||||
await getSystemShell(platformOverride, await this._shellEnvironmentService.getShellEnv()),
|
||||
process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'),
|
||||
process.env.windir,
|
||||
createVariableResolver(lastActiveWorkspace, this._configurationResolverService),
|
||||
|
@ -87,6 +90,7 @@ export class TerminalInstanceService extends Disposable implements ITerminalInst
|
|||
useAutomationShell,
|
||||
platformOverride
|
||||
);
|
||||
|
||||
const args = getDefaultShellArgs(
|
||||
(key) => this._configurationService.inspect(key),
|
||||
isWorkspaceShellAllowed,
|
||||
|
@ -95,6 +99,7 @@ export class TerminalInstanceService extends Disposable implements ITerminalInst
|
|||
this._logService,
|
||||
platformOverride
|
||||
);
|
||||
|
||||
return Promise.resolve({ shell, args });
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue