提交 426bdb61 编写于 作者: D Daniel Imms

Don't fail silently

上级 4ae3714e
......@@ -597,7 +597,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
// Get the initial cwd
const terminalConfig = configProvider.getConfiguration('terminal.integrated');
const initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, os.homedir(), lastActiveWorkspace ? lastActiveWorkspace : undefined, this._variableResolver, activeWorkspaceRootUri, terminalConfig.cwd);
const initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, os.homedir(), lastActiveWorkspace ? lastActiveWorkspace : undefined, this._variableResolver, activeWorkspaceRootUri, terminalConfig.cwd, this._logService);
const envFromConfig = this._apiInspectConfigToPlain(configProvider.getConfiguration('terminal.integrated').inspect<ITerminalEnvironment>(`env.${platformKey}`));
const baseEnv = terminalConfig.get<boolean>('inheritEnv', true) ? process.env as platform.IProcessEnvironment : await this._getNonInheritedEnv();
......
......@@ -211,7 +211,15 @@ export class TerminalProcessManager implements ITerminalProcessManager {
}
}
const initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, this._environmentService.userHome, lastActiveWorkspace ? lastActiveWorkspace : undefined, this._configurationResolverService, activeWorkspaceRootUri, this._configHelper.config.cwd);
const initialCwd = terminalEnvironment.getCwd(
shellLaunchConfig,
this._environmentService.userHome,
lastActiveWorkspace ? lastActiveWorkspace : undefined,
this._configurationResolverService,
activeWorkspaceRootUri,
this._configHelper.config.cwd,
this._logService
);
const envFromConfigValue = this._workspaceConfigurationService.inspect<ITerminalEnvironment | undefined>(`terminal.integrated.env.${platformKey}`);
const isWorkspaceShellAllowed = this._configHelper.checkWorkspaceShellPermissions();
this._configHelper.showRecommendations(shellLaunchConfig);
......
......@@ -10,6 +10,7 @@ import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IShellLaunchConfig, ITerminalEnvironment } from 'vs/workbench/contrib/terminal/common/terminal';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { sanitizeProcessEnvironment } from 'vs/base/common/processes';
import { ILogService } from 'vs/platform/log/common/log';
/**
* This module contains utility functions related to the environment, cwd and paths.
......@@ -119,20 +120,30 @@ function _getLangEnvVariable(locale?: string) {
return parts.join('_') + '.UTF-8';
}
export function getCwd(shell: IShellLaunchConfig, userHome: string, lastActiveWorkspace: IWorkspaceFolder | undefined, configurationResolverService: IConfigurationResolverService | undefined, root: Uri | undefined, customCwd: string | undefined): string {
export function getCwd(
shell: IShellLaunchConfig,
userHome: string,
lastActiveWorkspace: IWorkspaceFolder | undefined,
configurationResolverService: IConfigurationResolverService | undefined,
root: Uri | undefined,
customCwd: string | undefined,
logService: ILogService
): string {
if (shell.cwd) {
return (typeof shell.cwd === 'object') ? shell.cwd.fsPath : shell.cwd;
}
let cwd: string | undefined;
// TODO: Handle non-existent customCwd
if (!shell.ignoreConfigurationCwd && customCwd) {
if (configurationResolverService) {
try {
cwd = configurationResolverService.resolve(lastActiveWorkspace, customCwd);
} catch {
cwd = undefined;
} catch (e) {
// There was an issue resolving a variable, just use the unresolved customCwd which
// which will fail, and log the error in the console.
cwd = customCwd;
logService.error('Resolving terminal.integrated.cwd', e);
}
}
if (path.isAbsolute(customCwd) && !cwd) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册