@@ -13,7 +13,6 @@ import { Registry } from 'vs/platform/registry/common/platform';
1313import * as errors from 'vs/base/common/errors' ;
1414import { IConfigurationService , ConfigurationTarget } from 'vs/platform/configuration/common/configuration' ;
1515import { IConfigurationRegistry , Extensions as ConfigurationExtensions , IConfigurationPropertySchema , IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry' ;
16- import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
1716import { ColorThemeData } from './colorThemeData' ;
1817import { ITheme , Extensions as ThemingExtensions , IThemingRegistry } from 'vs/platform/theme/common/themeService' ;
1918import { Event , Emitter } from 'vs/base/common/event' ;
@@ -85,7 +84,6 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
8584 private watchedIconThemeLocation : URI | undefined ;
8685
8786 private themingParticipantChangeListener : IDisposable ;
88- private _configurationWriter : ConfigurationWriter ;
8987
9088 private get colorCustomizations ( ) : IColorCustomizations {
9189 return this . configurationService . getValue < IColorCustomizations > ( CUSTOM_WORKBENCH_COLORS_SETTING ) || { } ;
@@ -101,7 +99,6 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
10199 @IConfigurationService private readonly configurationService : IConfigurationService ,
102100 @ITelemetryService private readonly telemetryService : ITelemetryService ,
103101 @IWindowService private readonly windowService : IWindowService ,
104- @IInstantiationService private readonly instantiationService : IInstantiationService ,
105102 @IEnvironmentService private readonly environmentService : IEnvironmentService
106103 ) {
107104
@@ -429,7 +426,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
429426
430427 private writeColorThemeConfiguration ( settingsTarget : ConfigurationTarget | undefined | 'auto' ) : Promise < IColorTheme > {
431428 if ( ! types . isUndefinedOrNull ( settingsTarget ) ) {
432- return this . configurationWriter . writeConfiguration ( COLOR_THEME_SETTING , this . currentColorTheme . settingsId , settingsTarget ) . then ( _ => this . currentColorTheme ) ;
429+ return this . writeConfiguration ( COLOR_THEME_SETTING , this . currentColorTheme . settingsId , settingsTarget ) . then ( _ => this . currentColorTheme ) ;
433430 }
434431 return Promise . resolve ( this . currentColorTheme ) ;
435432 }
@@ -538,17 +535,38 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
538535
539536 private writeFileIconConfiguration ( settingsTarget : ConfigurationTarget | undefined | 'auto' ) : Promise < IFileIconTheme > {
540537 if ( ! types . isUndefinedOrNull ( settingsTarget ) ) {
541- return this . configurationWriter . writeConfiguration ( ICON_THEME_SETTING , this . currentIconTheme . settingsId , settingsTarget ) . then ( _ => this . currentIconTheme ) ;
538+ return this . writeConfiguration ( ICON_THEME_SETTING , this . currentIconTheme . settingsId , settingsTarget ) . then ( _ => this . currentIconTheme ) ;
542539 }
543540 return Promise . resolve ( this . currentIconTheme ) ;
544541 }
545542
546- private get configurationWriter ( ) : ConfigurationWriter {
547- // separate out the ConfigurationWriter to avoid a dependency of the IConfigurationEditingService
548- if ( ! this . _configurationWriter ) {
549- this . _configurationWriter = this . instantiationService . createInstance ( ConfigurationWriter ) ;
543+ public writeConfiguration ( key : string , value : any , settingsTarget : ConfigurationTarget | 'auto' ) : Promise < void > {
544+ let settings = this . configurationService . inspect ( key ) ;
545+ if ( settingsTarget === 'auto' ) {
546+ if ( ! types . isUndefined ( settings . workspaceFolder ) ) {
547+ settingsTarget = ConfigurationTarget . WORKSPACE_FOLDER ;
548+ } else if ( ! types . isUndefined ( settings . workspace ) ) {
549+ settingsTarget = ConfigurationTarget . WORKSPACE ;
550+ } else {
551+ settingsTarget = ConfigurationTarget . USER ;
552+ }
550553 }
551- return this . _configurationWriter ;
554+
555+ if ( settingsTarget === ConfigurationTarget . USER ) {
556+ if ( value === settings . user ) {
557+ return Promise . resolve ( undefined ) ; // nothing to do
558+ } else if ( value === settings . default ) {
559+ if ( types . isUndefined ( settings . user ) ) {
560+ return Promise . resolve ( undefined ) ; // nothing to do
561+ }
562+ value = undefined ; // remove configuration from user settings
563+ }
564+ } else if ( settingsTarget === ConfigurationTarget . WORKSPACE || settingsTarget === ConfigurationTarget . WORKSPACE_FOLDER ) {
565+ if ( value === settings . value ) {
566+ return Promise . resolve ( undefined ) ; // nothing to do
567+ }
568+ }
569+ return this . configurationService . updateValue ( key , value , settingsTarget ) ;
552570 }
553571
554572 private getBaseThemeFromContainer ( ) {
@@ -585,40 +603,6 @@ function _applyRules(styleSheetContent: string, rulesClassName: string) {
585603registerColorThemeSchemas ( ) ;
586604registerFileIconThemeSchemas ( ) ;
587605
588- class ConfigurationWriter {
589- constructor ( @IConfigurationService private readonly configurationService : IConfigurationService ) {
590- }
591-
592- public writeConfiguration ( key : string , value : any , settingsTarget : ConfigurationTarget | 'auto' ) : Promise < void > {
593- let settings = this . configurationService . inspect ( key ) ;
594- if ( settingsTarget === 'auto' ) {
595- if ( ! types . isUndefined ( settings . workspaceFolder ) ) {
596- settingsTarget = ConfigurationTarget . WORKSPACE_FOLDER ;
597- } else if ( ! types . isUndefined ( settings . workspace ) ) {
598- settingsTarget = ConfigurationTarget . WORKSPACE ;
599- } else {
600- settingsTarget = ConfigurationTarget . USER ;
601- }
602- }
603-
604- if ( settingsTarget === ConfigurationTarget . USER ) {
605- if ( value === settings . user ) {
606- return Promise . resolve ( undefined ) ; // nothing to do
607- } else if ( value === settings . default ) {
608- if ( types . isUndefined ( settings . user ) ) {
609- return Promise . resolve ( undefined ) ; // nothing to do
610- }
611- value = undefined ; // remove configuration from user settings
612- }
613- } else if ( settingsTarget === ConfigurationTarget . WORKSPACE || settingsTarget === ConfigurationTarget . WORKSPACE_FOLDER ) {
614- if ( value === settings . value ) {
615- return Promise . resolve ( undefined ) ; // nothing to do
616- }
617- }
618- return this . configurationService . updateValue ( key , value , settingsTarget ) ;
619- }
620- }
621-
622606// Configuration: Themes
623607const configurationRegistry = Registry . as < IConfigurationRegistry > ( ConfigurationExtensions . Configuration ) ;
624608
0 commit comments