diff --git a/extensions/css/package.json b/extensions/css/package.json index ade1d96be90..471bce75046 100644 --- a/extensions/css/package.json +++ b/extensions/css/package.json @@ -70,7 +70,8 @@ "type": "boolean", "scope": "window", "default": true, - "description": "%css.colorDecorators.enable.desc%" + "description": "%css.colorDecorators.enable.desc%", + "deprecationMessage": "%css.colorDecorators.enable.deprecationMessage%" }, "css.lint.compatibleVendorPrefixes": { "type": "string", @@ -303,7 +304,8 @@ "type": "boolean", "scope": "window", "default": true, - "description": "%scss.colorDecorators.enable.desc%" + "description": "%scss.colorDecorators.enable.desc%", + "deprecationMessage": "%scss.colorDecorators.enable.deprecationMessage%" }, "scss.lint.compatibleVendorPrefixes": { "type": "string", @@ -526,7 +528,8 @@ "type": "boolean", "scope": "window", "default": true, - "description": "%less.colorDecorators.enable.desc%" + "description": "%less.colorDecorators.enable.desc%", + "deprecationMessage": "%less.colorDecorators.enable.deprecationMessage%" }, "less.lint.compatibleVendorPrefixes": { "type": "string", diff --git a/extensions/css/package.nls.json b/extensions/css/package.nls.json index a5f76536626..3881a4e7e38 100644 --- a/extensions/css/package.nls.json +++ b/extensions/css/package.nls.json @@ -58,5 +58,8 @@ "scss.validate.desc": "Enables or disables all validations", "less.colorDecorators.enable.desc": "Enables or disables color decorators", "scss.colorDecorators.enable.desc": "Enables or disables color decorators", - "css.colorDecorators.enable.desc": "Enables or disables color decorators" + "css.colorDecorators.enable.desc": "Enables or disables color decorators", + "css.colorDecorators.enable.deprecationMessage": "The setting `css.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`.", + "scss.colorDecorators.enable.deprecationMessage": "The setting `scss.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`.", + "less.colorDecorators.enable.deprecationMessage": "The setting `less.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`." } \ No newline at end of file diff --git a/extensions/json/package.json b/extensions/json/package.json index 655cb125db1..c6801851d39 100644 --- a/extensions/json/package.json +++ b/extensions/json/package.json @@ -118,7 +118,8 @@ "type": "boolean", "scope": "window", "default": true, - "description": "%json.colorDecorators.enable.desc%" + "description": "%json.colorDecorators.enable.desc%", + "deprecationMessage": "%json.colorDecorators.enable.deprecationMessage%" } } }, diff --git a/extensions/json/package.nls.json b/extensions/json/package.nls.json index 0a04365fbf4..31385fd819f 100644 --- a/extensions/json/package.nls.json +++ b/extensions/json/package.nls.json @@ -6,5 +6,6 @@ "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.", "json.format.enable.desc": "Enable/disable default JSON formatter (requires restart)", "json.tracing.desc": "Traces the communication between VS Code and the JSON language server.", - "json.colorDecorators.enable.desc": "Enables or disables color decorators" + "json.colorDecorators.enable.desc": "Enables or disables color decorators", + "json.colorDecorators.enable.deprecationMessage": "The setting `json.colorDecorators.enable` has been deprecated in favor of `editor.colorDecorators`." } \ No newline at end of file diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index b11f83290c4..941a9f8be6e 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -593,10 +593,10 @@ const editorConfiguration: IConfigurationNode = { 'default': EDITOR_DEFAULTS.contribInfo.links, 'description': nls.localize('links', "Controls whether the editor should detect links and make them clickable") }, - 'editor.colorDecorator': { + 'editor.colorDecorators': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.colorDecorator, - 'description': nls.localize('colorDecorator', "Controls whether the editor should render the inline color decorators.") + 'default': EDITOR_DEFAULTS.contribInfo.colorDecorators, + 'description': nls.localize('colorDecorators', "Controls whether the editor should render the inline color decorators.") }, 'diffEditor.renderSideBySide': { 'type': 'boolean', diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 1bb3a55518e..d25c4210ae6 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -340,7 +340,7 @@ export interface IEditorOptions { /** * Enable inline color decorators rendering. */ - colorDecorator?: boolean; + colorDecorators?: boolean; /** * Enable custom contextmenu. * Defaults to true. @@ -794,7 +794,7 @@ export interface EditorContribOptions { readonly showFoldingControls: 'always' | 'mouseover'; readonly matchBrackets: boolean; readonly find: InternalEditorFindOptions; - readonly colorDecorator: boolean; + readonly colorDecorators: boolean; } /** @@ -1139,7 +1139,7 @@ export class InternalEditorOptions { && a.showFoldingControls === b.showFoldingControls && a.matchBrackets === b.matchBrackets && this._equalFindOptions(a.find, b.find) - && a.colorDecorator === b.colorDecorator + && a.colorDecorators === b.colorDecorators ); } @@ -1668,7 +1668,7 @@ export class EditorOptionsValidator { showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']), matchBrackets: _boolean(opts.matchBrackets, defaults.matchBrackets), find: find, - colorDecorator: _boolean(opts.colorDecorator, defaults.colorDecorator), + colorDecorators: _boolean(opts.colorDecorators, defaults.colorDecorators), }; } } @@ -1766,7 +1766,7 @@ export class InternalEditorOptionsFactory { showFoldingControls: opts.contribInfo.showFoldingControls, matchBrackets: (accessibilityIsOn ? false : opts.contribInfo.matchBrackets), // DISABLED WHEN SCREEN READER IS ATTACHED find: opts.contribInfo.find, - colorDecorator: opts.contribInfo.colorDecorator + colorDecorators: opts.contribInfo.colorDecorators } }; } @@ -2205,6 +2205,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { seedSearchStringFromSelection: true, autoFindInSelection: false }, - colorDecorator: true + colorDecorators: true }, }; diff --git a/src/vs/editor/contrib/colorPicker/browser/colorController.ts b/src/vs/editor/contrib/colorPicker/browser/colorController.ts index f3fbc6c58ab..3fa617e4c51 100644 --- a/src/vs/editor/contrib/colorPicker/browser/colorController.ts +++ b/src/vs/editor/contrib/colorPicker/browser/colorController.ts @@ -11,6 +11,7 @@ import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService' import { hash } from 'vs/base/common/hash'; import { ColorProviderRegistry } from 'vs/editor/common/modes'; import { RGBA } from 'vs/base/common/color'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; const MAX_DECORATORS = 500; @@ -29,27 +30,54 @@ export class ColorController extends Disposable implements IEditorContribution { constructor( private _editor: ICodeEditor, - @ICodeEditorService private _codeEditorService: ICodeEditorService + @ICodeEditorService private _codeEditorService: ICodeEditorService, + @IConfigurationService private _configurationService: IConfigurationService, ) { super(); - this._isEnabled = this._editor.getConfiguration().contribInfo.colorDecorator; + this._isEnabled = this.isEnabled(); this._decorations = []; this._decorationsTypes = {}; - this._register(_editor.onDidChangeModel((e) => this.triggerUpdateDecorations())); + this._register(_editor.onDidChangeModel((e) => { + this._isEnabled = this.isEnabled(); + this.triggerUpdateDecorations(); + })); this._register(_editor.onDidChangeModelContent((e) => { setTimeout(() => this.triggerUpdateDecorations(), 0); })); - this._register(_editor.onDidChangeModelLanguage((e) => this.triggerUpdateDecorations())); - this._register(_editor.onDidChangeConfiguration((e) => { + this._register(_configurationService.onDidUpdateConfiguration((e) => { let prevIsEnabled = this._isEnabled; - this._isEnabled = this._editor.getConfiguration().contribInfo.colorDecorator; + this._isEnabled = this.isEnabled(); + if (prevIsEnabled !== this._isEnabled) { + this.triggerUpdateDecorations(true); + } + })); + this._register(_editor.onDidChangeModelLanguage((e) => { + let prevIsEnabled = this._isEnabled; + this._isEnabled = this.isEnabled(); if (prevIsEnabled !== this._isEnabled) { this.triggerUpdateDecorations(true); } })); this._register(ColorProviderRegistry.onDidChange((e) => this.triggerUpdateDecorations())); - this.triggerUpdateDecorations(); + } + + isEnabled(): boolean { + const model = this._editor.getModel(); + if (!model) { + return false; + } + const languageId = model.getLanguageIdentifier(); + // handle deprecated settings. [languageId].colorDecorators.enable + let deprecatedConfig = this._configurationService.getConfiguration(languageId.language); + if (deprecatedConfig) { + let colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable'); + if (colorDecorators && colorDecorators['enable'] !== undefined) { + return colorDecorators['enable']; + } + } + + return this._editor.getConfiguration().contribInfo.colorDecorators; } triggerUpdateDecorations(settingsChanges = false) { diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 8ec845078ac..a85354ef584 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2892,7 +2892,7 @@ declare module monaco.editor { /** * Enable inline color decorators rendering. */ - colorDecorator?: boolean; + colorDecorators?: boolean; /** * Enable custom contextmenu. * Defaults to true. @@ -3290,7 +3290,7 @@ declare module monaco.editor { readonly showFoldingControls: 'always' | 'mouseover'; readonly matchBrackets: boolean; readonly find: InternalEditorFindOptions; - readonly colorDecorator: boolean; + readonly colorDecorators: boolean; } /** diff --git a/src/vs/platform/telemetry/common/telemetryUtils.ts b/src/vs/platform/telemetry/common/telemetryUtils.ts index af3d18219c0..d1c8b3db156 100644 --- a/src/vs/platform/telemetry/common/telemetryUtils.ts +++ b/src/vs/platform/telemetry/common/telemetryUtils.ts @@ -143,7 +143,7 @@ const configurationValueWhitelist = [ 'editor.stablePeek', 'editor.dragAndDrop', 'editor.formatOnSave', - 'editor.colorDecorator', + 'editor.colorDecorators', 'window.zoomLevel', 'files.autoSave',