Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1 (#8722)

* Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1

* remove tests that aren't working
This commit is contained in:
Anthony Dresser
2019-12-18 00:14:28 -08:00
committed by GitHub
parent 0fd870d156
commit 30d9e9c141
289 changed files with 5537 additions and 3039 deletions

View File

@@ -196,13 +196,13 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
// Check if workspace setting exists and whether it's whitelisted
let isWorkspaceShellAllowed: boolean | undefined = false;
if (shellConfigValue.workspace !== undefined || shellArgsConfigValue.workspace !== undefined || envConfigValue.workspace !== undefined) {
if (shellConfigValue.workspaceValue !== undefined || shellArgsConfigValue.workspaceValue !== undefined || envConfigValue.workspaceValue !== undefined) {
isWorkspaceShellAllowed = this.isWorkspaceShellAllowed(undefined);
}
// Always allow [] args as it would lead to an odd error message and should not be dangerous
if (shellConfigValue.workspace === undefined && envConfigValue.workspace === undefined &&
shellArgsConfigValue.workspace && shellArgsConfigValue.workspace.length === 0) {
if (shellConfigValue.workspaceValue === undefined && envConfigValue.workspaceValue === undefined &&
shellArgsConfigValue.workspaceValue && shellArgsConfigValue.workspaceValue.length === 0) {
isWorkspaceShellAllowed = true;
}
@@ -210,16 +210,16 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
// permission
if (isWorkspaceShellAllowed === undefined) {
let shellString: string | undefined;
if (shellConfigValue.workspace) {
shellString = `shell: "${shellConfigValue.workspace}"`;
if (shellConfigValue.workspaceValue) {
shellString = `shell: "${shellConfigValue.workspaceValue}"`;
}
let argsString: string | undefined;
if (shellArgsConfigValue.workspace) {
argsString = `shellArgs: [${shellArgsConfigValue.workspace.map(v => '"' + v + '"').join(', ')}]`;
if (shellArgsConfigValue.workspaceValue) {
argsString = `shellArgs: [${shellArgsConfigValue.workspaceValue.map(v => '"' + v + '"').join(', ')}]`;
}
let envString: string | undefined;
if (envConfigValue.workspace) {
envString = `env: {${Object.keys(envConfigValue.workspace).map(k => `${k}:${envConfigValue.workspace![k]}`).join(', ')}}`;
if (envConfigValue.workspaceValue) {
envString = `env: {${Object.keys(envConfigValue.workspaceValue).map(k => `${k}:${envConfigValue.workspaceValue![k]}`).join(', ')}}`;
}
// Should not be localized as it's json-like syntax referencing settings keys
const workspaceConfigStrings: string[] = [];

View File

@@ -138,8 +138,18 @@ export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [
'workbench.action.debug.stepInto',
'workbench.action.debug.stepOut',
'workbench.action.debug.stepOver',
'workbench.action.nextEditor',
'workbench.action.previousEditor',
'workbench.action.nextEditorInGroup',
'workbench.action.previousEditorInGroup',
'workbench.action.openNextRecentlyUsedEditor',
'workbench.action.openPreviousRecentlyUsedEditor',
'workbench.action.openNextRecentlyUsedEditorInGroup',
'workbench.action.openPreviousRecentlyUsedEditorInGroup',
'workbench.action.quickOpenNextRecentlyUsedEditor',
'workbench.action.quickOpenPreviousRecentlyUsedEditor',
'workbench.action.quickOpenNextRecentlyUsedEditorInGroup',
'workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup',
'workbench.action.focusActiveEditorGroup',
'workbench.action.focusFirstEditorGroup',
'workbench.action.focusLastEditorGroup',

View File

@@ -246,7 +246,7 @@ export function escapeNonWindowsPath(path: string): string {
}
export function getDefaultShell(
fetchSetting: (key: string) => { user?: string | string[], value?: string | string[], default?: string | string[] },
fetchSetting: (key: string) => { userValue?: string | string[], value?: string | string[], defaultValue?: string | string[] },
isWorkspaceShellAllowed: boolean,
defaultShell: string,
isWoW64: boolean,
@@ -294,7 +294,7 @@ export function getDefaultShell(
}
export function getDefaultShellArgs(
fetchSetting: (key: string) => { user?: string | string[], value?: string | string[], default?: string | string[] },
fetchSetting: (key: string) => { userValue?: string | string[], value?: string | string[], defaultValue?: string | string[] },
isWorkspaceShellAllowed: boolean,
useAutomationShell: boolean,
lastActiveWorkspace: IWorkspaceFolder | undefined,
@@ -310,7 +310,10 @@ export function getDefaultShellArgs(
const platformKey = platformOverride === platform.Platform.Windows ? 'windows' : platformOverride === platform.Platform.Mac ? 'osx' : 'linux';
const shellArgsConfigValue = fetchSetting(`terminal.integrated.shellArgs.${platformKey}`);
let args = <string[] | string>((isWorkspaceShellAllowed ? shellArgsConfigValue.value : shellArgsConfigValue.user) || shellArgsConfigValue.default);
let args = ((isWorkspaceShellAllowed ? shellArgsConfigValue.value : shellArgsConfigValue.userValue) || shellArgsConfigValue.defaultValue);
if (!args) {
return [];
}
if (typeof args === 'string' && platformOverride === platform.Platform.Windows) {
return configurationResolverService ? configurationResolverService.resolve(lastActiveWorkspace, args) : args;
}
@@ -330,21 +333,21 @@ export function getDefaultShellArgs(
}
function getShellSetting(
fetchSetting: (key: string) => { user?: string | string[], value?: string | string[], default?: string | string[] },
fetchSetting: (key: string) => { userValue?: string | string[], value?: string | string[], defaultValue?: string | string[] },
isWorkspaceShellAllowed: boolean,
type: 'automationShell' | 'shell',
platformOverride: platform.Platform = platform.platform,
): string | null {
const platformKey = platformOverride === platform.Platform.Windows ? 'windows' : platformOverride === platform.Platform.Mac ? 'osx' : 'linux';
const shellConfigValue = fetchSetting(`terminal.integrated.${type}.${platformKey}`);
const executable = (isWorkspaceShellAllowed ? <string>shellConfigValue.value : <string>shellConfigValue.user) || (<string | null>shellConfigValue.default);
const executable = (isWorkspaceShellAllowed ? <string>shellConfigValue.value : <string>shellConfigValue.userValue) || (<string | null>shellConfigValue.defaultValue);
return executable;
}
export function createTerminalEnvironment(
shellLaunchConfig: IShellLaunchConfig,
lastActiveWorkspace: IWorkspaceFolder | null,
envFromConfig: { user?: ITerminalEnvironment, value?: ITerminalEnvironment, default?: ITerminalEnvironment },
envFromConfig: { userValue?: ITerminalEnvironment, value?: ITerminalEnvironment, defaultValue?: ITerminalEnvironment },
configurationResolverService: IConfigurationResolverService | undefined,
isWorkspaceShellAllowed: boolean,
version: string | undefined,
@@ -362,7 +365,7 @@ export function createTerminalEnvironment(
// const platformKey = platform.isWindows ? 'windows' : (platform.isMacintosh ? 'osx' : 'linux');
// const envFromConfigValue = this._workspaceConfigurationService.inspect<ITerminalEnvironment | undefined>(`terminal.integrated.env.${platformKey}`);
const allowedEnvFromConfig = { ...(isWorkspaceShellAllowed ? envFromConfig.value : envFromConfig.user) };
const allowedEnvFromConfig = { ...(isWorkspaceShellAllowed ? envFromConfig.value : envFromConfig.userValue) };
// Resolve env vars from config and shell
if (configurationResolverService) {

View File

@@ -213,7 +213,7 @@ suite('Workbench - TerminalEnvironment', () => {
test('should change Sysnative to System32 in non-WoW64 systems', () => {
const shell = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'C:\\Windows\\Sysnative\\cmd.exe', value: undefined, default: undefined }
'terminal.integrated.shell.windows': { userValue: 'C:\\Windows\\Sysnative\\cmd.exe', value: undefined, defaultValue: undefined }
} as any)[key];
}, false, 'DEFAULT', false, 'C:\\Windows', undefined, undefined, {} as any, false, platform.Platform.Windows);
assert.equal(shell, 'C:\\Windows\\System32\\cmd.exe');
@@ -222,7 +222,7 @@ suite('Workbench - TerminalEnvironment', () => {
test('should not change Sysnative to System32 in WoW64 systems', () => {
const shell = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'C:\\Windows\\Sysnative\\cmd.exe', value: undefined, default: undefined }
'terminal.integrated.shell.windows': { userValue: 'C:\\Windows\\Sysnative\\cmd.exe', value: undefined, defaultValue: undefined }
} as any)[key];
}, false, 'DEFAULT', true, 'C:\\Windows', undefined, undefined, {} as any, false, platform.Platform.Windows);
assert.equal(shell, 'C:\\Windows\\Sysnative\\cmd.exe');
@@ -231,22 +231,22 @@ suite('Workbench - TerminalEnvironment', () => {
test('should use automationShell when specified', () => {
const shell1 = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'shell', value: undefined, default: undefined },
'terminal.integrated.automationShell.windows': { user: undefined, value: undefined, default: undefined }
'terminal.integrated.shell.windows': { userValue: 'shell', value: undefined, defaultValue: undefined },
'terminal.integrated.automationShell.windows': { userValue: undefined, value: undefined, defaultValue: undefined }
} as any)[key];
}, false, 'DEFAULT', false, 'C:\\Windows', undefined, undefined, {} as any, false, platform.Platform.Windows);
assert.equal(shell1, 'shell', 'automationShell was false');
const shell2 = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'shell', value: undefined, default: undefined },
'terminal.integrated.automationShell.windows': { user: undefined, value: undefined, default: undefined }
'terminal.integrated.shell.windows': { userValue: 'shell', value: undefined, defaultValue: undefined },
'terminal.integrated.automationShell.windows': { userValue: undefined, value: undefined, defaultValue: undefined }
} as any)[key];
}, false, 'DEFAULT', false, 'C:\\Windows', undefined, undefined, {} as any, true, platform.Platform.Windows);
assert.equal(shell2, 'shell', 'automationShell was true');
const shell3 = getDefaultShell(key => {
return ({
'terminal.integrated.shell.windows': { user: 'shell', value: undefined, default: undefined },
'terminal.integrated.automationShell.windows': { user: 'automationShell', value: undefined, default: undefined }
'terminal.integrated.shell.windows': { userValue: 'shell', value: undefined, defaultValue: undefined },
'terminal.integrated.automationShell.windows': { userValue: 'automationShell', value: undefined, defaultValue: undefined }
} as any)[key];
}, false, 'DEFAULT', false, 'C:\\Windows', undefined, undefined, {} as any, true, platform.Platform.Windows);
assert.equal(shell3, 'automationShell', 'automationShell was true and specified in settings');