提交 1e3cc1a3 编写于 作者: D Daniel Imms

Don't fail hard when shell/shellArgs vars aren't resolved

Fixes #78307
上级 23875a28
...@@ -371,7 +371,8 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape { ...@@ -371,7 +371,8 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'), process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'),
process.env.windir, process.env.windir,
this._lastActiveWorkspace, this._lastActiveWorkspace,
this._variableResolver this._variableResolver,
this._logService
); );
} }
...@@ -383,7 +384,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape { ...@@ -383,7 +384,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
return this._apiInspectConfigToPlain<string | string[]>(setting); return this._apiInspectConfigToPlain<string | string[]>(setting);
}; };
return terminalEnvironment.getDefaultShellArgs(fetchSetting, this._isWorkspaceShellAllowed, this._lastActiveWorkspace, this._variableResolver); return terminalEnvironment.getDefaultShellArgs(fetchSetting, this._isWorkspaceShellAllowed, this._lastActiveWorkspace, this._variableResolver, this._logService);
} }
public async resolveTerminalRenderer(id: number): Promise<vscode.TerminalRenderer> { public async resolveTerminalRenderer(id: number): Promise<vscode.TerminalRenderer> {
......
...@@ -78,7 +78,11 @@ function resolveConfigurationVariables(configurationResolverService: IConfigurat ...@@ -78,7 +78,11 @@ function resolveConfigurationVariables(configurationResolverService: IConfigurat
Object.keys(env).forEach((key) => { Object.keys(env).forEach((key) => {
const value = env[key]; const value = env[key];
if (typeof value === 'string' && lastActiveWorkspaceRoot !== null) { if (typeof value === 'string' && lastActiveWorkspaceRoot !== null) {
env[key] = configurationResolverService.resolve(lastActiveWorkspaceRoot, value); try {
env[key] = configurationResolverService.resolve(lastActiveWorkspaceRoot, value);
} catch (e) {
env[key] = value;
}
} }
}); });
return env; return env;
...@@ -143,7 +147,7 @@ export function getCwd( ...@@ -143,7 +147,7 @@ export function getCwd(
// There was an issue resolving a variable, just use the unresolved customCwd which // There was an issue resolving a variable, just use the unresolved customCwd which
// which will fail, and log the error in the console. // which will fail, and log the error in the console.
if (logService) { if (logService) {
logService.error('Resolving terminal.integrated.cwd', e); logService.error('Could not resolve terminal.integrated.cwd', e);
} }
return customCwd; return customCwd;
} }
...@@ -192,7 +196,8 @@ export function getDefaultShell( ...@@ -192,7 +196,8 @@ export function getDefaultShell(
windir: string | undefined, windir: string | undefined,
lastActiveWorkspace: IWorkspaceFolder | undefined, lastActiveWorkspace: IWorkspaceFolder | undefined,
configurationResolverService: IConfigurationResolverService | undefined, configurationResolverService: IConfigurationResolverService | undefined,
platformOverride: platform.Platform = platform.platform, logService: ILogService,
platformOverride: platform.Platform = platform.platform
): string { ): string {
const platformKey = platformOverride === platform.Platform.Windows ? 'windows' : platformOverride === platform.Platform.Mac ? 'osx' : 'linux'; const platformKey = platformOverride === platform.Platform.Windows ? 'windows' : platformOverride === platform.Platform.Mac ? 'osx' : 'linux';
const shellConfigValue = fetchSetting(`terminal.integrated.shell.${platformKey}`); const shellConfigValue = fetchSetting(`terminal.integrated.shell.${platformKey}`);
...@@ -214,7 +219,12 @@ export function getDefaultShell( ...@@ -214,7 +219,12 @@ export function getDefaultShell(
} }
if (configurationResolverService) { if (configurationResolverService) {
executable = configurationResolverService.resolve(lastActiveWorkspace, executable); try {
executable = configurationResolverService.resolve(lastActiveWorkspace, executable);
} catch (e) {
logService.error(`Could not resolve terminal.integrated.shell.${platformKey}`, e);
executable = executable;
}
} }
return executable; return executable;
...@@ -225,6 +235,7 @@ export function getDefaultShellArgs( ...@@ -225,6 +235,7 @@ export function getDefaultShellArgs(
isWorkspaceShellAllowed: boolean, isWorkspaceShellAllowed: boolean,
lastActiveWorkspace: IWorkspaceFolder | undefined, lastActiveWorkspace: IWorkspaceFolder | undefined,
configurationResolverService: IConfigurationResolverService | undefined, configurationResolverService: IConfigurationResolverService | undefined,
logService: ILogService,
platformOverride: platform.Platform = platform.platform, platformOverride: platform.Platform = platform.platform,
): string | string[] { ): string | string[] {
const platformKey = platformOverride === platform.Platform.Windows ? 'windows' : platformOverride === platform.Platform.Mac ? 'osx' : 'linux'; const platformKey = platformOverride === platform.Platform.Windows ? 'windows' : platformOverride === platform.Platform.Mac ? 'osx' : 'linux';
...@@ -236,7 +247,12 @@ export function getDefaultShellArgs( ...@@ -236,7 +247,12 @@ export function getDefaultShellArgs(
if (configurationResolverService) { if (configurationResolverService) {
const resolvedArgs: string[] = []; const resolvedArgs: string[] = [];
for (const arg of args) { for (const arg of args) {
resolvedArgs.push(configurationResolverService.resolve(lastActiveWorkspace, arg)); try {
resolvedArgs.push(configurationResolverService.resolve(lastActiveWorkspace, arg));
} catch (e) {
logService.error(`Could not resolve terminal.integrated.shellArgs.${platformKey}`, e);
resolvedArgs.push(arg);
}
} }
args = resolvedArgs; args = resolvedArgs;
} }
......
...@@ -20,6 +20,7 @@ import { getMainProcessParentEnv } from 'vs/workbench/contrib/terminal/node/term ...@@ -20,6 +20,7 @@ import { getMainProcessParentEnv } from 'vs/workbench/contrib/terminal/node/term
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ILogService } from 'vs/platform/log/common/log';
let Terminal: typeof XTermTerminal; let Terminal: typeof XTermTerminal;
let WebLinksAddon: typeof XTermWebLinksAddon; let WebLinksAddon: typeof XTermWebLinksAddon;
...@@ -34,7 +35,8 @@ export class TerminalInstanceService implements ITerminalInstanceService { ...@@ -34,7 +35,8 @@ export class TerminalInstanceService implements ITerminalInstanceService {
@IStorageService private readonly _storageService: IStorageService, @IStorageService private readonly _storageService: IStorageService,
@IConfigurationResolverService private readonly _configurationResolverService: IConfigurationResolverService, @IConfigurationResolverService private readonly _configurationResolverService: IConfigurationResolverService,
@IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService, @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService,
@IHistoryService private readonly _historyService: IHistoryService @IHistoryService private readonly _historyService: IHistoryService,
@ILogService private readonly _logService: ILogService
) { ) {
} }
...@@ -84,6 +86,7 @@ export class TerminalInstanceService implements ITerminalInstanceService { ...@@ -84,6 +86,7 @@ export class TerminalInstanceService implements ITerminalInstanceService {
process.env.windir, process.env.windir,
lastActiveWorkspace, lastActiveWorkspace,
this._configurationResolverService, this._configurationResolverService,
this._logService,
platformOverride platformOverride
); );
const args = getDefaultShellArgs( const args = getDefaultShellArgs(
...@@ -91,6 +94,7 @@ export class TerminalInstanceService implements ITerminalInstanceService { ...@@ -91,6 +94,7 @@ export class TerminalInstanceService implements ITerminalInstanceService {
isWorkspaceShellAllowed, isWorkspaceShellAllowed,
lastActiveWorkspace, lastActiveWorkspace,
this._configurationResolverService, this._configurationResolverService,
this._logService,
platformOverride platformOverride
); );
return Promise.resolve({ shell, args }); return Promise.resolve({ shell, args });
...@@ -99,4 +103,4 @@ export class TerminalInstanceService implements ITerminalInstanceService { ...@@ -99,4 +103,4 @@ export class TerminalInstanceService implements ITerminalInstanceService {
public getMainProcessParentEnv(): Promise<IProcessEnvironment> { public getMainProcessParentEnv(): Promise<IProcessEnvironment> {
return getMainProcessParentEnv(); return getMainProcessParentEnv();
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册