@@ -21,6 +21,10 @@ import { getCodeInsetData, ICodeInsetData } from './codeinset';
2121import { registerEditorContribution } from 'vs/editor/browser/editorExtensions' ;
2222import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
2323import { MainThreadWebviews } from 'vs/workbench/api/electron-browser/mainThreadWebview' ;
24+ import { Registry } from 'vs/platform/registry/common/platform' ;
25+ import { IConfigurationRegistry , Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry' ;
26+ import { localize } from 'vs/nls.mock' ;
27+ import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
2428
2529export class CodeInsetController implements editorCommon . IEditorContribution {
2630
@@ -41,9 +45,10 @@ export class CodeInsetController implements editorCommon.IEditorContribution {
4145 private _editor : editorBrowser . ICodeEditor ,
4246 @ICommandService private readonly _commandService : ICommandService ,
4347 @INotificationService private readonly _notificationService : INotificationService ,
44- @IExtensionService private readonly _extensionService : IExtensionService
48+ @IExtensionService private readonly _extensionService : IExtensionService ,
49+ @IConfigurationService private readonly _configService : IConfigurationService ,
4550 ) {
46- this . _isEnabled = this . _editor . getConfiguration ( ) . contribInfo . codeInsets ;
51+ this . _isEnabled = this . _configService . getValue < boolean > ( 'editor. codeInsets' ) ;
4752
4853 this . _globalToDispose = [ ] ;
4954 this . _localToDispose = [ ] ;
@@ -53,11 +58,13 @@ export class CodeInsetController implements editorCommon.IEditorContribution {
5358
5459 this . _globalToDispose . push ( this . _editor . onDidChangeModel ( ( ) => this . _onModelChange ( ) ) ) ;
5560 this . _globalToDispose . push ( this . _editor . onDidChangeModelLanguage ( ( ) => this . _onModelChange ( ) ) ) ;
56- this . _globalToDispose . push ( this . _editor . onDidChangeConfiguration ( ( ) => {
57- let prevIsEnabled = this . _isEnabled ;
58- this . _isEnabled = this . _editor . getConfiguration ( ) . contribInfo . codeInsets ;
59- if ( prevIsEnabled !== this . _isEnabled ) {
60- this . _onModelChange ( ) ;
61+ this . _globalToDispose . push ( this . _configService . onDidChangeConfiguration ( e => {
62+ if ( e . affectsConfiguration ( 'editor.codeInsets' ) ) {
63+ let prevIsEnabled = this . _isEnabled ;
64+ this . _isEnabled = this . _configService . getValue < boolean > ( 'editor.codeInsets' ) ;
65+ if ( prevIsEnabled !== this . _isEnabled ) {
66+ this . _onModelChange ( ) ;
67+ }
6168 }
6269 } ) ) ;
6370 this . _globalToDispose . push ( CodeInsetProviderRegistry . onDidChange ( this . _onModelChange , this ) ) ;
@@ -333,3 +340,15 @@ export class CodeInsetController implements editorCommon.IEditorContribution {
333340}
334341
335342registerEditorContribution ( CodeInsetController ) ;
343+
344+
345+ Registry . as < IConfigurationRegistry > ( ConfigurationExtensions . Configuration ) . registerConfiguration ( {
346+ id : 'editor' ,
347+ properties : {
348+ [ 'editor.codeInsets' ] : {
349+ description : localize ( 'editor.codeInsets' , "Enable/disable editor code insets" ) ,
350+ type : 'boolean' ,
351+ default : false
352+ }
353+ }
354+ } ) ;
0 commit comments