Skip to content

Commit ef690de

Browse files
committed
Config migration
1 parent 9355b43 commit ef690de

9 files changed

Lines changed: 61 additions & 25 deletions

File tree

extensions/css/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
"type": "boolean",
7171
"scope": "window",
7272
"default": true,
73-
"description": "%css.colorDecorators.enable.desc%"
73+
"description": "%css.colorDecorators.enable.desc%",
74+
"deprecationMessage": "%css.colorDecorators.enable.deprecationMessage%"
7475
},
7576
"css.lint.compatibleVendorPrefixes": {
7677
"type": "string",
@@ -303,7 +304,8 @@
303304
"type": "boolean",
304305
"scope": "window",
305306
"default": true,
306-
"description": "%scss.colorDecorators.enable.desc%"
307+
"description": "%scss.colorDecorators.enable.desc%",
308+
"deprecationMessage": "%scss.colorDecorators.enable.deprecationMessage%"
307309
},
308310
"scss.lint.compatibleVendorPrefixes": {
309311
"type": "string",
@@ -526,7 +528,8 @@
526528
"type": "boolean",
527529
"scope": "window",
528530
"default": true,
529-
"description": "%less.colorDecorators.enable.desc%"
531+
"description": "%less.colorDecorators.enable.desc%",
532+
"deprecationMessage": "%less.colorDecorators.enable.deprecationMessage%"
530533
},
531534
"less.lint.compatibleVendorPrefixes": {
532535
"type": "string",

extensions/css/package.nls.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,8 @@
5858
"scss.validate.desc": "Enables or disables all validations",
5959
"less.colorDecorators.enable.desc": "Enables or disables color decorators",
6060
"scss.colorDecorators.enable.desc": "Enables or disables color decorators",
61-
"css.colorDecorators.enable.desc": "Enables or disables color decorators"
61+
"css.colorDecorators.enable.desc": "Enables or disables color decorators",
62+
"css.colorDecorators.enable.deprecationMessage": "The setting `css.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`.",
63+
"scss.colorDecorators.enable.deprecationMessage": "The setting `scss.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`.",
64+
"less.colorDecorators.enable.deprecationMessage": "The setting `less.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`."
6265
}

extensions/json/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"type": "boolean",
119119
"scope": "window",
120120
"default": true,
121-
"description": "%json.colorDecorators.enable.desc%"
121+
"description": "%json.colorDecorators.enable.desc%",
122+
"deprecationMessage": "%json.colorDecorators.enable.deprecationMessage%"
122123
}
123124
}
124125
},

extensions/json/package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"json.schemas.schema.desc": "The schema definition for the given URL. The schema only needs to be provided to avoid accesses to the schema URL.",
77
"json.format.enable.desc": "Enable/disable default JSON formatter (requires restart)",
88
"json.tracing.desc": "Traces the communication between VS Code and the JSON language server.",
9-
"json.colorDecorators.enable.desc": "Enables or disables color decorators"
9+
"json.colorDecorators.enable.desc": "Enables or disables color decorators",
10+
"json.colorDecorators.enable.deprecationMessage": "The setting `json.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`."
1011
}

src/vs/editor/common/config/commonEditorConfig.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,10 @@ const editorConfiguration: IConfigurationNode = {
593593
'default': EDITOR_DEFAULTS.contribInfo.links,
594594
'description': nls.localize('links', "Controls whether the editor should detect links and make them clickable")
595595
},
596-
'editor.colorDecorator': {
596+
'editor.colorDecorators': {
597597
'type': 'boolean',
598-
'default': EDITOR_DEFAULTS.contribInfo.colorDecorator,
599-
'description': nls.localize('colorDecorator', "Controls whether the editor should render the inline color decorators.")
598+
'default': EDITOR_DEFAULTS.contribInfo.colorDecorators,
599+
'description': nls.localize('colorDecorators', "Controls whether the editor should render the inline color decorators.")
600600
},
601601
'diffEditor.renderSideBySide': {
602602
'type': 'boolean',

src/vs/editor/common/config/editorOptions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export interface IEditorOptions {
340340
/**
341341
* Enable inline color decorators rendering.
342342
*/
343-
colorDecorator?: boolean;
343+
colorDecorators?: boolean;
344344
/**
345345
* Enable custom contextmenu.
346346
* Defaults to true.
@@ -794,7 +794,7 @@ export interface EditorContribOptions {
794794
readonly showFoldingControls: 'always' | 'mouseover';
795795
readonly matchBrackets: boolean;
796796
readonly find: InternalEditorFindOptions;
797-
readonly colorDecorator: boolean;
797+
readonly colorDecorators: boolean;
798798
}
799799

800800
/**
@@ -1139,7 +1139,7 @@ export class InternalEditorOptions {
11391139
&& a.showFoldingControls === b.showFoldingControls
11401140
&& a.matchBrackets === b.matchBrackets
11411141
&& this._equalFindOptions(a.find, b.find)
1142-
&& a.colorDecorator === b.colorDecorator
1142+
&& a.colorDecorators === b.colorDecorators
11431143
);
11441144
}
11451145

@@ -1668,7 +1668,7 @@ export class EditorOptionsValidator {
16681668
showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
16691669
matchBrackets: _boolean(opts.matchBrackets, defaults.matchBrackets),
16701670
find: find,
1671-
colorDecorator: _boolean(opts.colorDecorator, defaults.colorDecorator),
1671+
colorDecorators: _boolean(opts.colorDecorators, defaults.colorDecorators),
16721672
};
16731673
}
16741674
}
@@ -1766,7 +1766,7 @@ export class InternalEditorOptionsFactory {
17661766
showFoldingControls: opts.contribInfo.showFoldingControls,
17671767
matchBrackets: (accessibilityIsOn ? false : opts.contribInfo.matchBrackets), // DISABLED WHEN SCREEN READER IS ATTACHED
17681768
find: opts.contribInfo.find,
1769-
colorDecorator: opts.contribInfo.colorDecorator
1769+
colorDecorators: opts.contribInfo.colorDecorators
17701770
}
17711771
};
17721772
}
@@ -2205,6 +2205,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
22052205
seedSearchStringFromSelection: true,
22062206
autoFindInSelection: false
22072207
},
2208-
colorDecorator: true
2208+
colorDecorators: true
22092209
},
22102210
};

src/vs/editor/contrib/colorPicker/browser/colorController.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService'
1111
import { hash } from 'vs/base/common/hash';
1212
import { ColorProviderRegistry } from 'vs/editor/common/modes';
1313
import { RGBA } from 'vs/base/common/color';
14+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1415

1516
const MAX_DECORATORS = 500;
1617

@@ -29,27 +30,54 @@ export class ColorController extends Disposable implements IEditorContribution {
2930

3031
constructor(
3132
private _editor: ICodeEditor,
32-
@ICodeEditorService private _codeEditorService: ICodeEditorService
33+
@ICodeEditorService private _codeEditorService: ICodeEditorService,
34+
@IConfigurationService private _configurationService: IConfigurationService,
3335
) {
3436
super();
35-
this._isEnabled = this._editor.getConfiguration().contribInfo.colorDecorator;
37+
this._isEnabled = this.isEnabled();
3638
this._decorations = [];
3739
this._decorationsTypes = {};
38-
this._register(_editor.onDidChangeModel((e) => this.triggerUpdateDecorations()));
40+
this._register(_editor.onDidChangeModel((e) => {
41+
this._isEnabled = this.isEnabled();
42+
this.triggerUpdateDecorations();
43+
}));
3944
this._register(_editor.onDidChangeModelContent((e) => {
4045
setTimeout(() => this.triggerUpdateDecorations(), 0);
4146
}));
42-
this._register(_editor.onDidChangeModelLanguage((e) => this.triggerUpdateDecorations()));
43-
this._register(_editor.onDidChangeConfiguration((e) => {
47+
this._register(_configurationService.onDidUpdateConfiguration((e) => {
48+
let prevIsEnabled = this._isEnabled;
49+
this._isEnabled = this.isEnabled();
50+
if (prevIsEnabled !== this._isEnabled) {
51+
this.triggerUpdateDecorations(true);
52+
}
53+
}));
54+
this._register(_editor.onDidChangeModelLanguage((e) => {
4455
let prevIsEnabled = this._isEnabled;
45-
this._isEnabled = this._editor.getConfiguration().contribInfo.colorDecorator;
56+
this._isEnabled = this.isEnabled();
4657
if (prevIsEnabled !== this._isEnabled) {
4758
this.triggerUpdateDecorations(true);
4859
}
4960
}));
5061

5162
this._register(ColorProviderRegistry.onDidChange((e) => this.triggerUpdateDecorations()));
52-
this.triggerUpdateDecorations();
63+
}
64+
65+
isEnabled(): boolean {
66+
const model = this._editor.getModel();
67+
if (!model) {
68+
return false;
69+
}
70+
const languageId = model.getLanguageIdentifier();
71+
// handle deprecated settings. [languageId].colorDecorators.enable
72+
let deprecatedConfig = this._configurationService.getConfiguration(languageId.language);
73+
if (deprecatedConfig) {
74+
let colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
75+
if (colorDecorators && colorDecorators['enable'] !== undefined) {
76+
return colorDecorators['enable'];
77+
}
78+
}
79+
80+
return this._editor.getConfiguration().contribInfo.colorDecorators;
5381
}
5482

5583
triggerUpdateDecorations(settingsChanges = false) {

src/vs/monaco.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ declare module monaco.editor {
28922892
/**
28932893
* Enable inline color decorators rendering.
28942894
*/
2895-
colorDecorator?: boolean;
2895+
colorDecorators?: boolean;
28962896
/**
28972897
* Enable custom contextmenu.
28982898
* Defaults to true.
@@ -3290,7 +3290,7 @@ declare module monaco.editor {
32903290
readonly showFoldingControls: 'always' | 'mouseover';
32913291
readonly matchBrackets: boolean;
32923292
readonly find: InternalEditorFindOptions;
3293-
readonly colorDecorator: boolean;
3293+
readonly colorDecorators: boolean;
32943294
}
32953295

32963296
/**

src/vs/platform/telemetry/common/telemetryUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const configurationValueWhitelist = [
143143
'editor.stablePeek',
144144
'editor.dragAndDrop',
145145
'editor.formatOnSave',
146-
'editor.colorDecorator',
146+
'editor.colorDecorators',
147147

148148
'window.zoomLevel',
149149
'files.autoSave',

0 commit comments

Comments
 (0)