mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Config migration
This commit is contained in:
parent
9355b436d1
commit
ef690ded3e
|
@ -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",
|
||||
|
|
|
@ -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`."
|
||||
}
|
|
@ -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%"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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`."
|
||||
}
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
4
src/vs/monaco.d.ts
vendored
4
src/vs/monaco.d.ts
vendored
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,7 +143,7 @@ const configurationValueWhitelist = [
|
|||
'editor.stablePeek',
|
||||
'editor.dragAndDrop',
|
||||
'editor.formatOnSave',
|
||||
'editor.colorDecorator',
|
||||
'editor.colorDecorators',
|
||||
|
||||
'window.zoomLevel',
|
||||
'files.autoSave',
|
||||
|
|
Loading…
Reference in a new issue