@@ -45,6 +45,10 @@ export type TokenStyleDefinitions = { [P in keyof TokenStyleData]?: TokenStyleDe
45
45
46
46
export type TextMateThemingRuleDefinitions = { [ P in keyof TokenStyleData ] ?: ITextMateThemingRule | undefined ; } & { scope ?: ProbeScope } ;
47
47
48
+ interface IColorOrDefaultMap {
49
+ [ id : string ] : Color | typeof DEFAULT_COLOR_CONFIG_VALUE ;
50
+ }
51
+
48
52
export class ColorThemeData implements IWorkbenchColorTheme {
49
53
50
54
static readonly STORAGE_KEY = 'colorThemeData' ;
@@ -65,7 +69,7 @@ export class ColorThemeData implements IWorkbenchColorTheme {
65
69
private themeTokenColors : ITextMateThemingRule [ ] = [ ] ;
66
70
private customTokenColors : ITextMateThemingRule [ ] = [ ] ;
67
71
private colorMap : IColorMap = { } ;
68
- private customColorMap : IColorMap = { } ;
72
+ private customColorMap : IColorOrDefaultMap = { } ;
69
73
70
74
private semanticTokenRules : SemanticTokenRule [ ] = [ ] ;
71
75
private customSemanticTokenRules : SemanticTokenRule [ ] = [ ] ;
@@ -132,15 +136,20 @@ export class ColorThemeData implements IWorkbenchColorTheme {
132
136
}
133
137
134
138
public getColor ( colorId : ColorIdentifier , useDefault ?: boolean ) : Color | undefined {
135
- let color : Color | undefined = this . customColorMap [ colorId ] ;
136
- if ( color ) {
137
- return color ;
139
+ const customColor = this . customColorMap [ colorId ] ;
140
+ if ( customColor instanceof Color ) {
141
+ return customColor ;
142
+ }
143
+ if ( customColor === undefined ) { /* !== DEFAULT_COLOR_CONFIG_VALUE */
144
+ const color = this . colorMap [ colorId ] ;
145
+ if ( color !== undefined ) {
146
+ return color ;
147
+ }
138
148
}
139
- color = this . colorMap [ colorId ] ;
140
- if ( useDefault !== false && types . isUndefined ( color ) ) {
141
- color = this . getDefault ( colorId ) ;
149
+ if ( useDefault !== false ) {
150
+ return this . getDefault ( colorId ) ;
142
151
}
143
- return color ;
152
+ return undefined ;
144
153
}
145
154
146
155
private getTokenStyle ( type : string , modifiers : string [ ] , language : string , useDefault = true , definitions : TokenStyleDefinitions = { } ) : TokenStyle | undefined {
@@ -346,7 +355,11 @@ export class ColorThemeData implements IWorkbenchColorTheme {
346
355
}
347
356
348
357
public defines ( colorId : ColorIdentifier ) : boolean {
349
- return this . customColorMap . hasOwnProperty ( colorId ) || this . colorMap . hasOwnProperty ( colorId ) ;
358
+ const customColor = this . customColorMap [ colorId ] ;
359
+ if ( customColor instanceof Color ) {
360
+ return true ;
361
+ }
362
+ return customColor === undefined /* !== DEFAULT_COLOR_CONFIG_VALUE */ && this . colorMap . hasOwnProperty ( colorId ) ;
350
363
}
351
364
352
365
public setCustomizations ( settings : ThemeConfiguration ) {
@@ -373,7 +386,7 @@ export class ColorThemeData implements IWorkbenchColorTheme {
373
386
for ( const id in colors ) {
374
387
const colorVal = colors [ id ] ;
375
388
if ( colorVal === DEFAULT_COLOR_CONFIG_VALUE ) {
376
- delete this . colorMap [ id ] ;
389
+ this . customColorMap [ id ] = DEFAULT_COLOR_CONFIG_VALUE ;
377
390
} else if ( typeof colorVal === 'string' ) {
378
391
this . customColorMap [ id ] = Color . fromHex ( colorVal ) ;
379
392
}
@@ -719,9 +732,9 @@ async function _loadColorTheme(extensionResourceLoaderService: IExtensionResourc
719
732
// new JSON color themes format
720
733
for ( const colorId in colors ) {
721
734
const colorVal = colors [ colorId ] ;
722
- if ( colorVal === DEFAULT_COLOR_CONFIG_VALUE ) {
735
+ if ( colorVal === DEFAULT_COLOR_CONFIG_VALUE ) { // ignore colors that are set to to default
723
736
delete result . colors [ colorId ] ;
724
- } else if ( typeof colorVal === 'string' ) { // ignore colors that are null
737
+ } else if ( typeof colorVal === 'string' ) {
725
738
result . colors [ colorId ] = Color . fromHex ( colors [ colorId ] ) ;
726
739
}
727
740
}
0 commit comments