Skip to content

Commit 054a929

Browse files
authored
Merge pull request #123174 from microsoft/tyriar/r156_defaultProfile
Switch priority of shell/shellArgs and defaultProfile setting
2 parents 26f617a + e95e22e commit 054a929

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
109109
}
110110
}
111111

112+
// If either shell or shellArgs are specified, they will take priority for now until we
113+
// allow users to migrate, see https://github.com/microsoft/vscode/issues/123171
114+
if (this.getSafeConfigValue('shell', options.os) || this.getSafeConfigValue('shellArgs', options.os, false)) {
115+
return this._getFallbackDefaultProfile(options);
116+
}
117+
112118
// Return the real default profile if it exists and is valid
113119
const defaultProfile = await this._getRealDefaultProfile(false, options.os);
114120
if (defaultProfile) {
@@ -137,18 +143,18 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
137143

138144
private async _getFallbackDefaultProfile(options: IShellLaunchConfigResolveOptions): Promise<ITerminalProfile> {
139145
let executable: string;
140-
let args: string | string[] | undefined;
141146
const shellSetting = this.getSafeConfigValue('shell', options.os);
142147
if (this._isValidShell(shellSetting)) {
143148
executable = shellSetting;
144-
const shellArgsSetting = this.getSafeConfigValue('shellArgs', options.os);
145-
if (this._isValidShellArgs(shellArgsSetting, options.os)) {
146-
args = shellArgsSetting;
147-
}
148149
} else {
149150
executable = await this._context.getDefaultSystemShell(options.remoteAuthority, options.os);
150151
}
151152

153+
let args: string | string[] | undefined;
154+
const shellArgsSetting = this.getSafeConfigValue('shellArgs', options.os);
155+
if (this._isValidShellArgs(shellArgsSetting, options.os)) {
156+
args = shellArgsSetting;
157+
}
152158
if (args === undefined) {
153159
if (options.os === OperatingSystem.Macintosh && args === undefined) {
154160
// macOS should launch a login shell by default
@@ -276,21 +282,21 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
276282
}
277283

278284
// TODO: Remove when workspace trust is enabled
279-
getSafeConfigValue(key: string, os: OperatingSystem): unknown | undefined {
280-
return this.getSafeConfigValueFullKey(`terminal.integrated.${key}.${this._getOsKey(os)}`);
285+
getSafeConfigValue(key: string, os: OperatingSystem, useDefaultValue: boolean = true): unknown | undefined {
286+
return this.getSafeConfigValueFullKey(`terminal.integrated.${key}.${this._getOsKey(os)}`, useDefaultValue);
281287
}
282-
getSafeConfigValueFullKey(key: string): unknown | undefined {
288+
getSafeConfigValueFullKey(key: string, useDefaultValue: boolean = true): unknown | undefined {
283289
const isWorkspaceConfigAllowed = this._configurationService.getValue('terminal.integrated.allowWorkspaceConfiguration');
284290
if (isWorkspaceConfigAllowed) {
285291
return this._configurationService.getValue(key);
286292
} else {
287293
const config = this._configurationService.inspect(key);
288-
const value = config.user?.value || config.default?.value;
294+
const value = config.user?.value || (useDefaultValue ? config.default?.value : undefined);
289295
// Clone if needed to allow extensibility
290296
if (Array.isArray(value)) {
291297
return value.slice();
292298
}
293-
if (typeof value === 'object') {
299+
if (value !== null && typeof value === 'object') {
294300
return { ...value };
295301
}
296302
return value;

src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const terminalProfileSchema: IJSONSchema = {
4747
}
4848
};
4949

50+
const shellDeprecationMessageLinux = localize('terminal.integrated.shell.linux.deprecation', "This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in {0} and setting its profile name as the default in {1}. This will currently take priority over the new profiles settings but that will change in the future.", '`#terminal.integrated.profiles.linux#`', '`#terminal.integrated.defaultProfile.linux#`');
51+
const shellDeprecationMessageOsx = localize('terminal.integrated.shell.osx.deprecation', "This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in {0} and setting its profile name as the default in {1}. This will currently take priority over the new profiles settings but that will change in the future.", '`#terminal.integrated.profiles.osx#`', '`#terminal.integrated.defaultProfile.osx#`');
52+
const shellDeprecationMessageWindows = localize('terminal.integrated.shell.windows.deprecation', "This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in {0} and setting its profile name as the default in {1}. This will currently take priority over the new profiles settings but that will change in the future.", '`#terminal.integrated.profiles.windows#`', '`#terminal.integrated.defaultProfile.windows#`');
53+
5054
export const terminalConfiguration: IConfigurationNode = {
5155
id: 'terminal',
5256
order: 100,
@@ -93,7 +97,7 @@ export const terminalConfiguration: IConfigurationNode = {
9397
type: 'string'
9498
},
9599
default: [],
96-
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.linux#` instead'
100+
markdownDeprecationMessage: shellDeprecationMessageLinux
97101
},
98102
'terminal.integrated.shellArgs.osx': {
99103
restricted: true,
@@ -106,7 +110,7 @@ export const terminalConfiguration: IConfigurationNode = {
106110
// is the reason terminals on macOS typically run login shells by default which set up
107111
// the environment. See http://unix.stackexchange.com/a/119675/115410
108112
default: ['-l'],
109-
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.osx#` instead'
113+
markdownDeprecationMessage: shellDeprecationMessageOsx
110114
},
111115
'terminal.integrated.shellArgs.windows': {
112116
restricted: true,
@@ -125,7 +129,7 @@ export const terminalConfiguration: IConfigurationNode = {
125129
}
126130
],
127131
default: [],
128-
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.windows#` instead'
132+
markdownDeprecationMessage: shellDeprecationMessageWindows
129133
},
130134
'terminal.integrated.profiles.windows': {
131135
restricted: true,
@@ -261,19 +265,19 @@ export const terminalConfiguration: IConfigurationNode = {
261265
}
262266
},
263267
'terminal.integrated.defaultProfile.linux': {
264-
description: localize('terminal.integrated.defaultProfile.linux', 'The default profile used on Linux. When set to a valid profile name, this will override the values of `terminal.integrated.shell.osx` and `terminal.integrated.shellArgs.osx`.'),
268+
markdownDescription: localize('terminal.integrated.defaultProfile.linux', "The default profile used on Linux. This setting will currently be ignored if either {0} or {1} are set.", '`#terminal.integrated.shell.linux#`', '`#terminal.integrated.shellArgs.linux#`'),
265269
type: ['string', 'null'],
266270
default: null,
267271
scope: ConfigurationScope.APPLICATION // Disallow setting the default in workspace settings
268272
},
269273
'terminal.integrated.defaultProfile.osx': {
270-
description: localize('terminal.integrated.defaultProfile.osx', 'The default profile used on macOS. When set to a valid profile name, this will override the values of `terminal.integrated.shell.osx` and `terminal.integrated.shellArgs.osx`.'),
274+
description: localize('terminal.integrated.defaultProfile.osx', "The default profile used on macOS. This setting will currently be ignored if either {0} or {1} are set.", '`#terminal.integrated.shell.osx#`', '`#terminal.integrated.shellArgs.osx#`'),
271275
type: ['string', 'null'],
272276
default: null,
273277
scope: ConfigurationScope.APPLICATION // Disallow setting the default in workspace settings
274278
},
275279
'terminal.integrated.defaultProfile.windows': {
276-
description: localize('terminal.integrated.defaultProfile.windows', 'The default profile used on Windows. When set to a valid profile name, this will override the values of `terminal.integrated.shell.windows` and `terminal.integrated.shellArgs.windows`.'),
280+
description: localize('terminal.integrated.defaultProfile.windows', "The default profile used on Windows. This setting will currently be ignored if either {0} or {1} are set.", '`#terminal.integrated.shell.windows#`', '`#terminal.integrated.shellArgs.windows#`'),
277281
type: ['string', 'null'],
278282
default: null,
279283
scope: ConfigurationScope.APPLICATION // Disallow setting the default in workspace settings
@@ -682,21 +686,21 @@ function getTerminalShellConfigurationStub(linux: string, osx: string, windows:
682686
markdownDescription: linux,
683687
type: ['string', 'null'],
684688
default: null,
685-
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.linux#` instead'
689+
markdownDeprecationMessage: shellDeprecationMessageLinux
686690
},
687691
'terminal.integrated.shell.osx': {
688692
restricted: true,
689693
markdownDescription: osx,
690694
type: ['string', 'null'],
691695
default: null,
692-
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.osx#` instead'
696+
markdownDeprecationMessage: shellDeprecationMessageOsx
693697
},
694698
'terminal.integrated.shell.windows': {
695699
restricted: true,
696700
markdownDescription: windows,
697701
type: ['string', 'null'],
698702
default: null,
699-
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.windows#` instead'
703+
markdownDeprecationMessage: shellDeprecationMessageOsx
700704
}
701705
}
702706
};

0 commit comments

Comments
 (0)