@@ -44,6 +44,8 @@ const tokenGroupToScopesMap = {
4444export type TokenStyleDefinition = TokenStylingRule | ProbeScope [ ] | TokenStyleValue ;
4545export type TokenStyleDefinitions = { [ P in keyof TokenStyleData ] ?: TokenStyleDefinition | undefined } ;
4646
47+ export type TextMateThemingRuleDefinitions = { [ P in keyof TokenStyleData ] ?: ITextMateThemingRule | undefined ; } & { scope ?: ProbeScope ; } ;
48+
4749const PERSISTED_THEME_STORAGE_KEY = 'colorThemeData' ;
4850
4951export class ColorThemeData implements IWorkbenchColorTheme {
@@ -271,7 +273,8 @@ export class ColorThemeData implements IWorkbenchColorTheme {
271273 return colorRegistry . resolveDefaultColor ( colorId , this ) ;
272274 }
273275
274- public resolveScopes ( scopes : ProbeScope [ ] ) : TokenStyle | undefined {
276+
277+ public resolveScopes ( scopes : ProbeScope [ ] , definitions ?: TextMateThemingRuleDefinitions ) : TokenStyle | undefined {
275278
276279 if ( ! this . themeTokenScopeMatchers ) {
277280 this . themeTokenScopeMatchers = this . themeTokenColors . map ( getScopeMatcher ) ;
@@ -285,26 +288,37 @@ export class ColorThemeData implements IWorkbenchColorTheme {
285288 let fontStyle : string | undefined = undefined ;
286289 let foregroundScore = - 1 ;
287290 let fontStyleScore = - 1 ;
291+ let fontStyleThemingRule : ITextMateThemingRule | undefined = undefined ;
292+ let foregroundThemingRule : ITextMateThemingRule | undefined = undefined ;
288293
289- function findTokenStyleForScopeInScopes ( scopeMatchers : Matcher < ProbeScope > [ ] , tokenColors : ITextMateThemingRule [ ] ) {
294+ function findTokenStyleForScopeInScopes ( scopeMatchers : Matcher < ProbeScope > [ ] , themingRules : ITextMateThemingRule [ ] ) {
290295 for ( let i = 0 ; i < scopeMatchers . length ; i ++ ) {
291296 const score = scopeMatchers [ i ] ( scope ) ;
292297 if ( score >= 0 ) {
293- const settings = tokenColors [ i ] . settings ;
298+ const themingRule = themingRules [ i ] ;
299+ const settings = themingRules [ i ] . settings ;
294300 if ( score >= foregroundScore && settings . foreground ) {
295301 foreground = settings . foreground ;
296302 foregroundScore = score ;
303+ foregroundThemingRule = themingRule ;
297304 }
298305 if ( score >= fontStyleScore && types . isString ( settings . fontStyle ) ) {
299306 fontStyle = settings . fontStyle ;
300307 fontStyleScore = score ;
308+ fontStyleThemingRule = themingRule ;
301309 }
302310 }
303311 }
304312 }
305313 findTokenStyleForScopeInScopes ( this . themeTokenScopeMatchers , this . themeTokenColors ) ;
306314 findTokenStyleForScopeInScopes ( this . customTokenScopeMatchers , this . customTokenColors ) ;
307315 if ( foreground !== undefined || fontStyle !== undefined ) {
316+ if ( definitions ) {
317+ definitions . foreground = foregroundThemingRule ;
318+ definitions . bold = definitions . italic = definitions . underline = fontStyleThemingRule ;
319+ definitions . scope = scope ;
320+ }
321+
308322 return TokenStyle . fromSettings ( foreground , fontStyle ) ;
309323 }
310324 }
0 commit comments