Repository: microsoft/vscode (TypeScript) — Bug Fix

Issue:
Default terminal.integrated.defaultProfile.* value is invalid
Open default settings JSON:

![image](https://user-images.githubusercontent.com/2193314/161079185-5e23b42d-988b-4293-956a-05de2f518d28.png)

Version: 1.67.0-insider (user setup)
Commit: https://github.com/microsoft/vscode/commit/909602cf04e0fa42528d692676d0d4e15e67bba2
Date: 2022-03-31T11:00:49.798Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.22000


Discussion:
windows and linux issue only - works on mac
<img width="481" alt="Screen Shot 2022-03-31 at 11 16 55 AM" src="https://user-images.githubusercontent.com/29464607/161090326-05394648-f7de-4205-95a7-a04e718c4354.png">

but not in the settings editor actually
I think it happens on mac too, was originally reported for .osx
@aeschli any idea why null is not accepted here? We set null as a valid type along side enum/string:

https://github.com/microsoft/vscode/blob/e23908b71fca244509d9cbeb8305abaff1582421/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts#L510-L512


@rzhao271 any thoughts as I know you did some work related to enum settings?
Not sure, but I get a mysterious result `%debug.terminal.label%` in the suggestions:
![Terminal suggestions](https://user-images.githubusercontent.com/7199958/161152617-c78ad35e-84ee-4413-bb8b-fd908b71a449.PNG)

yeah that should be `JavaScript Debug Terminal`
@Tyriar If enums are defined, you need to add `null` as a valid value to the enums as well
> 
> 
> <img width="481" alt="Screen Shot 2022-03-31 at 11 16 55 AM" src="https://user-images.githubusercontent.com/29464607/161090326-05394648-f7de-4205-95a7-a04e718c4354.png">
> 
> 

@aeschli I believe null is already one of the enum values 
The completion values are composed of enum, default and more.
The validation only looks at at enum values.

So I'm quite sure the num values don't contain null, as the hover shows:
![image](https://user-images.githubusercontent.com/6461412/161239421-92e1d4d8-6f23-4c45-abaa-54925fe4b9f8.png)


Resolving patch:
diff --git a/src/vs/platform/terminal/common/terminalProfiles.ts b/src/vs/platform/terminal/common/terminalProfiles.ts
--- a/src/vs/platform/terminal/common/terminalProfiles.ts
+++ b/src/vs/platform/terminal/common/terminalProfiles.ts
@@ -5,19 +5,24 @@
 
 import { Codicon } from 'vs/base/common/codicons';
 import { URI, UriComponents } from 'vs/base/common/uri';
+import { localize } from 'vs/nls';
 import { IExtensionTerminalProfile, ITerminalProfile, TerminalIcon } from 'vs/platform/terminal/common/terminal';
 import { ThemeIcon } from 'vs/platform/theme/common/themeService';
 
 export function createProfileSchemaEnums(detectedProfiles: ITerminalProfile[], extensionProfiles?: readonly IExtensionTerminalProfile[]): {
-	values: string[] | undefined;
+	values: (string | null)[] | undefined;
 	markdownDescriptions: string[] | undefined;
 } {
-	const result = detectedProfiles.map(e => {
+	const result: { name: string | null; description: string }[] = [{
+		name: null,
+		description: localize('terminalAutomaticProfile', 'Automatically detect the default')
+	}];
+	result.push(...detectedProfiles.map(e => {
 		return {
 			name: e.profileName,
 			description: createProfileDescription(e)
 		};
-	});
+	}));
 	if (extensionProfiles) {
 		result.push(...extensionProfiles.map(extensionProfile => {
 			return {


Test patch:
diff --git a/src/vs/platform/terminal/test/common/terminalProfiles.test.ts b/src/vs/platform/terminal/test/common/terminalProfiles.test.ts
--- a/src/vs/platform/terminal/test/common/terminalProfiles.test.ts
+++ b/src/vs/platform/terminal/test/common/terminalProfiles.test.ts
@@ -12,8 +12,12 @@ suite('terminalProfiles', () => {
 	suite('createProfileSchemaEnums', () => {
 		test('should return an empty array when there are no profiles', () => {
 			deepStrictEqual(createProfileSchemaEnums([]), {
-				values: [],
-				markdownDescriptions: []
+				values: [
+					null
+				],
+				markdownDescriptions: [
+					'Automatically detect the default'
+				]
 			});
 		});
 		test('should return a single entry when there is one profile', () => {
@@ -23,8 +27,14 @@ suite('terminalProfiles', () => {
 				isDefault: true
 			};
 			deepStrictEqual(createProfileSchemaEnums([profile]), {
-				values: ['name'],
-				markdownDescriptions: ['$(terminal) name\n- path: path']
+				values: [
+					null,
+					'name'
+				],
+				markdownDescriptions: [
+					'Automatically detect the default',
+					'$(terminal) name\n- path: path'
+				]
 			});
 		});
 		test('should show all profile information', () => {
@@ -42,8 +52,14 @@ suite('terminalProfiles', () => {
 				overrideName: true
 			};
 			deepStrictEqual(createProfileSchemaEnums([profile]), {
-				values: ['name'],
-				markdownDescriptions: [`$(zap) name\n- path: path\n- args: ['a','b']\n- overrideName: true\n- color: terminal.ansiRed\n- env: {\"c\":\"d\",\"e\":\"f\"}`]
+				values: [
+					null,
+					'name'
+				],
+				markdownDescriptions: [
+					'Automatically detect the default',
+					`$(zap) name\n- path: path\n- args: ['a','b']\n- overrideName: true\n- color: terminal.ansiRed\n- env: {\"c\":\"d\",\"e\":\"f\"}`
+				]
 			});
 		});
 		test('should return a multiple entries when there are multiple profiles', () => {
@@ -58,8 +74,13 @@ suite('terminalProfiles', () => {
 				isDefault: false
 			};
 			deepStrictEqual(createProfileSchemaEnums([profile1, profile2]), {
-				values: ['name', 'foo'],
+				values: [
+					null,
+					'name',
+					'foo'
+				],
 				markdownDescriptions: [
+					'Automatically detect the default',
 					'$(terminal) name\n- path: path',
 					'$(terminal) foo\n- path: bar'
 				]