From 0de6a665cc8b753113b0265aad4821e972829004 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 Sep 2023 12:38:19 -0700 Subject: [PATCH 1/3] migrating over from booleans to enums --- src/vs/editor/browser/config/migrateOptions.ts | 15 +++++++++++++++ .../browser/codeActionsContribution.ts | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/vs/editor/browser/config/migrateOptions.ts b/src/vs/editor/browser/config/migrateOptions.ts index 362b68ce840f3..62ed682fc083f 100644 --- a/src/vs/editor/browser/config/migrateOptions.ts +++ b/src/vs/editor/browser/config/migrateOptions.ts @@ -192,3 +192,18 @@ registerEditorSettingMigration('experimental.stickyScroll.maxLineCount', (value, } } }); + +// Code Actions on Save +registerEditorSettingMigration('codeActionsOnSave', (value, read, write) => { + if (value && typeof value === 'object') { + const newValue = {} as any; + for (const entry of Object.entries(value)) { + if (typeof entry[1] === 'boolean') { + newValue[entry[0]] = entry[1] ? 'always' : 'never'; + } else { + newValue[entry[0]] = entry[1]; + } + } + write(`codeActionsOnSave`, newValue); + } +}); diff --git a/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts b/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts index bd0c4c4393c9b..d09cdb74047d7 100644 --- a/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts +++ b/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts @@ -37,7 +37,7 @@ const codeActionsOnSaveSchema: IConfigurationPropertySchema = { type: 'object', properties: codeActionsOnSaveDefaultProperties, additionalProperties: { - type: 'string' + type: 'string', }, }, { @@ -48,9 +48,10 @@ const codeActionsOnSaveSchema: IConfigurationPropertySchema = { markdownDescription: nls.localize('editor.codeActionsOnSave', 'Run CodeActions for the editor on save. CodeActions must be specified and the editor must not be shutting down. Example: `"source.organizeImports": "explicit" `'), type: 'object', additionalProperties: { - type: 'string' + type: 'string', + enum: ['always', 'never', 'explicit'], }, - default: {}, + default: { 'source.fixAll': 'never', 'source.organizeImports': 'never', }, scope: ConfigurationScope.LANGUAGE_OVERRIDABLE, }; From a1a827999f95c52699b7fe78a1390672b2394bae Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 Sep 2023 12:42:02 -0700 Subject: [PATCH 2/3] explicit not always --- src/vs/editor/browser/config/migrateOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/editor/browser/config/migrateOptions.ts b/src/vs/editor/browser/config/migrateOptions.ts index 62ed682fc083f..e86102d5b771d 100644 --- a/src/vs/editor/browser/config/migrateOptions.ts +++ b/src/vs/editor/browser/config/migrateOptions.ts @@ -199,7 +199,7 @@ registerEditorSettingMigration('codeActionsOnSave', (value, read, write) => { const newValue = {} as any; for (const entry of Object.entries(value)) { if (typeof entry[1] === 'boolean') { - newValue[entry[0]] = entry[1] ? 'always' : 'never'; + newValue[entry[0]] = entry[1] ? 'explicit' : 'never'; } else { newValue[entry[0]] = entry[1]; } From b02335c8bc16e8f402b61bc04d00c81eef221a8e Mon Sep 17 00:00:00 2001 From: Justin Chen <54879025+justschen@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:43:54 -0700 Subject: [PATCH 3/3] cleaned up and removed unused comma --- .../contrib/codeActions/browser/codeActionsContribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts b/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts index d09cdb74047d7..885daecd05efe 100644 --- a/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts +++ b/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts @@ -37,7 +37,7 @@ const codeActionsOnSaveSchema: IConfigurationPropertySchema = { type: 'object', properties: codeActionsOnSaveDefaultProperties, additionalProperties: { - type: 'string', + type: 'string' }, }, {