@@ -31,6 +31,7 @@ import { textmateColorsSchemaId, registerColorThemeSchemas, textmateColorSetting
3131import { workbenchColorsSchemaId } from 'vs/platform/theme/common/colorRegistry' ;
3232import { registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
3333import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts' ;
34+ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService' ;
3435
3536// implementation
3637
@@ -96,10 +97,11 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
9697 @IConfigurationService private readonly configurationService : IConfigurationService ,
9798 @ITelemetryService private readonly telemetryService : ITelemetryService ,
9899 @IWorkbenchEnvironmentService private readonly environmentService : IWorkbenchEnvironmentService ,
99- @IFileService private readonly fileService : IFileService
100+ @IFileService private readonly fileService : IFileService ,
101+ @IWorkbenchLayoutService readonly layoutService : IWorkbenchLayoutService
100102 ) {
101103
102- this . container = document . body ;
104+ this . container = layoutService . getWorkbenchContainer ( ) ;
103105 this . colorThemeStore = new ColorThemeStore ( extensionService , ColorThemeData . createLoadedEmptyTheme ( DEFAULT_THEME_ID , DEFAULT_THEME_SETTING_VALUE ) ) ;
104106 this . onFileIconThemeChange = new Emitter < IFileIconTheme > ( ) ;
105107 this . iconThemeStore = new FileIconThemeStore ( extensionService ) ;
@@ -385,14 +387,13 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
385387 }
386388
387389 private applyTheme ( newTheme : ColorThemeData , settingsTarget : ConfigurationTarget | undefined | 'auto' , silent = false ) : Promise < IColorTheme | null > {
388- if ( this . container ) {
389- if ( this . currentColorTheme ) {
390- removeClasses ( this . container , this . currentColorTheme . id ) ;
391- } else {
392- removeClasses ( this . container , VS_DARK_THEME , VS_LIGHT_THEME , VS_HC_THEME ) ;
393- }
394- addClasses ( this . container , newTheme . id ) ;
390+ if ( this . currentColorTheme ) {
391+ removeClasses ( this . container , this . currentColorTheme . id ) ;
392+ } else {
393+ removeClasses ( this . container , VS_DARK_THEME , VS_LIGHT_THEME , VS_HC_THEME ) ;
395394 }
395+ addClasses ( this . container , newTheme . id ) ;
396+
396397 this . currentColorTheme = newTheme ;
397398 if ( ! this . themingParticipantChangeListener ) {
398399 this . themingParticipantChangeListener = themingRegistry . onThemingParticipantAdded ( _ => this . updateDynamicCSSRules ( this . currentColorTheme ) ) ;
@@ -512,12 +513,10 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
512513 private doSetFileIconTheme ( iconThemeData : FileIconThemeData ) : void {
513514 this . currentIconTheme = iconThemeData ;
514515
515- if ( this . container ) {
516- if ( iconThemeData . id ) {
517- addClasses ( this . container , fileIconsEnabledClass ) ;
518- } else {
519- removeClasses ( this . container , fileIconsEnabledClass ) ;
520- }
516+ if ( iconThemeData . id ) {
517+ addClasses ( this . container , fileIconsEnabledClass ) ;
518+ } else {
519+ removeClasses ( this . container , fileIconsEnabledClass ) ;
521520 }
522521
523522 if ( this . fileService && ! resources . isEqual ( iconThemeData . location , this . watchedIconThemeLocation ) ) {
@@ -574,12 +573,10 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
574573 }
575574
576575 private getBaseThemeFromContainer ( ) {
577- if ( this . container ) {
578- for ( let i = this . container . classList . length - 1 ; i >= 0 ; i -- ) {
579- const item = document . body . classList . item ( i ) ;
580- if ( item === VS_LIGHT_THEME || item === VS_DARK_THEME || item === VS_HC_THEME ) {
581- return item ;
582- }
576+ for ( let i = this . container . classList . length - 1 ; i >= 0 ; i -- ) {
577+ const item = this . container . classList . item ( i ) ;
578+ if ( item === VS_LIGHT_THEME || item === VS_DARK_THEME || item === VS_HC_THEME ) {
579+ return item ;
583580 }
584581 }
585582 return VS_DARK_THEME ;
0 commit comments