Skip to content

Commit

Permalink
Removed default settings for Code Actions on Save (microsoft#194409)
Browse files Browse the repository at this point in the history
* removed default settings

* removed whitespace

* changed wordage

* boolean and string enum together

* updated language around settings, mentioning things will be deprecated

* changed settings accross noteboks as well

* Update codeActionModel.ts
  • Loading branch information
justschen committed Sep 28, 2023
1 parent 4ceb99a commit 411d298
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
8 changes: 6 additions & 2 deletions src/vs/editor/browser/config/migrateOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,21 @@ registerEditorSettingMigration('experimental.stickyScroll.maxLineCount', (value,
}
});

// // Code Actions on Save
// Code Actions on Save
// registerEditorSettingMigration('codeActionsOnSave', (value, read, write) => {
// if (value && typeof value === 'object') {
// let toBeModified = false;
// const newValue = {} as any;
// for (const entry of Object.entries(value)) {
// if (typeof entry[1] === 'boolean') {
// toBeModified = true;
// newValue[entry[0]] = entry[1] ? 'explicit' : 'never';
// } else {
// newValue[entry[0]] = entry[1];
// }
// }
// write(`codeActionsOnSave`, newValue);
// if (toBeModified) {
// write(`codeActionsOnSave`, newValue);
// }
// }
// });
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensi

const createCodeActionsAutoSave = (description: string): IJSONSchema => {
return {
type: 'string',
enum: ['always', 'never', 'explicit'],
enumDescriptions: [nls.localize('alwaysSave', 'Always triggers Code Actions on save'), nls.localize('neverSave', 'Never triggers Code Actions on save'), nls.localize('explicitSave', 'Triggers Code Actions only when explicitly saved')],
default: 'explicit',
type: ['string', 'boolean'],
enum: ['always', 'explicit', 'never', true, false],
enumDescriptions: [
nls.localize('alwaysSave', 'Triggers Code Actions on explicit saves and auto saves triggered by window or focus changes.'),
nls.localize('explicitSave', 'Triggers Code Actions only when explicitly saved'),
nls.localize('neverSave', 'Never triggers Code Actions on save'),
nls.localize('explicitSaveBoolean', 'Triggers Code Actions only when explicitly saved. This value will be deprecated in favor of "explicit".'),
nls.localize('neverSaveBoolean', 'Never triggers Code Actions on save. This value will be deprecated in favor of "never".')
],
default: true,
description: description
};
};
Expand All @@ -37,7 +43,7 @@ const codeActionsOnSaveSchema: IConfigurationPropertySchema = {
type: 'object',
properties: codeActionsOnSaveDefaultProperties,
additionalProperties: {
type: 'string'
type: ['string', 'boolean']
},
},
{
Expand All @@ -48,10 +54,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',
enum: ['always', 'never', 'explicit'],
type: ['string', 'boolean'],
enum: ['always', 'explicit', 'never', true, false],
},
default: { 'source.fixAll': 'never', 'source.organizeImports': 'never', },
default: {},
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -964,14 +964,14 @@ configurationRegistry.registerConfiguration({
default: false
},
[NotebookSetting.codeActionsOnSave]: {
markdownDescription: nls.localize('notebook.codeActionsOnSave', "Run a series of CodeActions for a notebook on save. CodeActions must be specified, the file must not be saved after delay, and the editor must not be shutting down. Example: `source.fixAll: true`"),
markdownDescription: nls.localize('notebook.codeActionsOnSave', 'Run a series of CodeActions for a notebook on save. CodeActions must be specified, the file must not be saved after delay, and the editor must not be shutting down. Example: `"source.fixAll": "explicit"`'),
type: 'object',
additionalProperties: {
type: 'string',
enum: ['explicit', 'never'],
type: ['string', 'boolean'],
enum: ['explicit', 'never', true, false],
// enum: ['explicit', 'always', 'never'], -- autosave support needs to be built first
// nls.localize('always', 'Always triggers Code Actions on save, including autosave, focus, and window change events.'),
enumDescriptions: [nls.localize('explicit', 'Triggers Code Actions only when explicitly saved.', nls.localize('never', 'Never triggers Code Actions on save.'))],
enumDescriptions: [nls.localize('explicit', 'Triggers Code Actions only when explicitly saved.'), nls.localize('never', 'Never triggers Code Actions on save.'), nls.localize('explicitBoolean', 'Triggers Code Actions only when explicitly saved. This value will be deprecated in favor of "explicit".'), nls.localize('neverBoolean', 'Triggers Code Actions only when explicitly saved. This value will be deprecated in favor of "never".')],
},
default: {}
},
Expand Down

0 comments on commit 411d298

Please sign in to comment.