提交 bc659cf3 编写于 作者: J Johannes Rieken

move editor.codeInsets setting to its contribution because it isn't a monaco editor thing

上级 d02c8011
......@@ -600,11 +600,6 @@ export interface IEditorOptions {
* Defaults to true.
*/
codeLens?: boolean;
/**
* Show code insets
* Defaults to true.
*/
codeInsets?: boolean;
/**
* Control the behavior and rendering of the code action lightbulb.
*/
......@@ -1001,7 +996,6 @@ export interface EditorContribOptions {
readonly selectionHighlight: boolean;
readonly occurrencesHighlight: boolean;
readonly codeLens: boolean;
readonly codeInsets: boolean;
readonly folding: boolean;
readonly foldingStrategy: 'auto' | 'indentation';
readonly showFoldingControls: 'always' | 'mouseover';
......@@ -2057,7 +2051,6 @@ export class EditorOptionsValidator {
selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight),
occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight),
codeLens: _boolean(opts.codeLens, defaults.codeLens),
codeInsets: _boolean(opts.codeInsets, defaults.codeInsets),
folding: _boolean(opts.folding, defaults.folding),
foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']),
showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
......@@ -2171,7 +2164,6 @@ export class InternalEditorOptionsFactory {
selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
occurrencesHighlight: (accessibilityIsOn ? false : opts.contribInfo.occurrencesHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
codeLens: (accessibilityIsOn ? false : opts.contribInfo.codeLens), // DISABLED WHEN SCREEN READER IS ATTACHED
codeInsets: (accessibilityIsOn ? false : opts.contribInfo.codeInsets),
folding: (accessibilityIsOn ? false : opts.contribInfo.folding), // DISABLED WHEN SCREEN READER IS ATTACHED
foldingStrategy: opts.contribInfo.foldingStrategy,
showFoldingControls: opts.contribInfo.showFoldingControls,
......@@ -2661,7 +2653,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
selectionHighlight: true,
occurrencesHighlight: true,
codeLens: true,
codeInsets: true,
folding: true,
foldingStrategy: 'auto',
showFoldingControls: 'mouseover',
......
......@@ -2934,11 +2934,6 @@ declare namespace monaco.editor {
* Defaults to true.
*/
codeLens?: boolean;
/**
* Show code insets
* Defaults to true.
*/
codeInsets?: boolean;
/**
* Control the behavior and rendering of the code action lightbulb.
*/
......@@ -3276,7 +3271,6 @@ declare namespace monaco.editor {
readonly selectionHighlight: boolean;
readonly occurrencesHighlight: boolean;
readonly codeLens: boolean;
readonly codeInsets: boolean;
readonly folding: boolean;
readonly foldingStrategy: 'auto' | 'indentation';
readonly showFoldingControls: 'always' | 'mouseover';
......
......@@ -21,6 +21,10 @@ import { getCodeInsetData, ICodeInsetData } from './codeinset';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { MainThreadWebviews } from 'vs/workbench/api/electron-browser/mainThreadWebview';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { localize } from 'vs/nls.mock';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export class CodeInsetController implements editorCommon.IEditorContribution {
......@@ -41,9 +45,10 @@ export class CodeInsetController implements editorCommon.IEditorContribution {
private _editor: editorBrowser.ICodeEditor,
@ICommandService private readonly _commandService: ICommandService,
@INotificationService private readonly _notificationService: INotificationService,
@IExtensionService private readonly _extensionService: IExtensionService
@IExtensionService private readonly _extensionService: IExtensionService,
@IConfigurationService private readonly _configService: IConfigurationService,
) {
this._isEnabled = this._editor.getConfiguration().contribInfo.codeInsets;
this._isEnabled = this._configService.getValue<boolean>('editor.codeInsets');
this._globalToDispose = [];
this._localToDispose = [];
......@@ -53,12 +58,14 @@ export class CodeInsetController implements editorCommon.IEditorContribution {
this._globalToDispose.push(this._editor.onDidChangeModel(() => this._onModelChange()));
this._globalToDispose.push(this._editor.onDidChangeModelLanguage(() => this._onModelChange()));
this._globalToDispose.push(this._editor.onDidChangeConfiguration(() => {
this._globalToDispose.push(this._configService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('editor.codeInsets')) {
let prevIsEnabled = this._isEnabled;
this._isEnabled = this._editor.getConfiguration().contribInfo.codeInsets;
this._isEnabled = this._configService.getValue<boolean>('editor.codeInsets');
if (prevIsEnabled !== this._isEnabled) {
this._onModelChange();
}
}
}));
this._globalToDispose.push(CodeInsetProviderRegistry.onDidChange(this._onModelChange, this));
this._onModelChange();
......@@ -333,3 +340,15 @@ export class CodeInsetController implements editorCommon.IEditorContribution {
}
registerEditorContribution(CodeInsetController);
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
id: 'editor',
properties: {
['editor.codeInsets']: {
description: localize('editor.codeInsets', "Enable/disable editor code insets"),
type: 'boolean',
default: false
}
}
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册