@@ -10,6 +10,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
1010import { Emitter , Event } from 'vs/base/common/event' ;
1111import * as resources from 'vs/base/common/resources' ;
1212import * as types from 'vs/base/common/types' ;
13+ import { equals as equalArray } from 'vs/base/common/arrays' ;
1314import { URI } from 'vs/base/common/uri' ;
1415import { TokenizationResult , TokenizationResult2 } from 'vs/editor/common/core/token' ;
1516import { IState , ITokenizationSupport , LanguageId , TokenMetadata , TokenizationRegistry , StandardTokenType , LanguageIdentifier } from 'vs/editor/common/modes' ;
@@ -44,6 +45,7 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
4445 private _grammarFactory : TMGrammarFactory | null ;
4546 private _tokenizersRegistrations : IDisposable [ ] ;
4647 protected _currentTheme : IRawTheme | null ;
48+ protected _currentTokenColorMap : string [ ] | null ;
4749
4850 constructor (
4951 @IModeService private readonly _modeService : IModeService ,
@@ -65,6 +67,7 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
6567 this . _tokenizersRegistrations = [ ] ;
6668
6769 this . _currentTheme = null ;
70+ this . _currentTokenColorMap = null ;
6871
6972 grammarsExtPoint . setHandler ( ( extensions ) => {
7073 this . _grammarDefinitions = null ;
@@ -245,16 +248,17 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
245248 }
246249
247250 private _updateTheme ( grammarFactory : TMGrammarFactory , colorTheme : IColorTheme , forceUpdate : boolean ) : void {
248- if ( ! forceUpdate && this . _currentTheme && AbstractTextMateService . equalsTokenRules ( this . _currentTheme . settings , colorTheme . tokenColors ) ) {
251+ if ( ! forceUpdate && this . _currentTheme && this . _currentTokenColorMap && AbstractTextMateService . equalsTokenRules ( this . _currentTheme . settings , colorTheme . tokenColors ) && equalArray ( this . _currentTokenColorMap , colorTheme . tokenColorMap ) ) {
249252 return ;
250253 }
251254 this . _currentTheme = { name : colorTheme . label , settings : colorTheme . tokenColors } ;
252- this . _doUpdateTheme ( grammarFactory , this . _currentTheme ) ;
255+ this . _currentTokenColorMap = colorTheme . tokenColorMap ;
256+ this . _doUpdateTheme ( grammarFactory , this . _currentTheme , this . _currentTokenColorMap ) ;
253257 }
254258
255- protected _doUpdateTheme ( grammarFactory : TMGrammarFactory , theme : IRawTheme ) : void {
256- grammarFactory . setTheme ( theme ) ;
257- let colorMap = AbstractTextMateService . _toColorMap ( grammarFactory . getColorMap ( ) ) ;
259+ protected _doUpdateTheme ( grammarFactory : TMGrammarFactory , theme : IRawTheme , tokenColorMap : string [ ] ) : void {
260+ grammarFactory . setTheme ( theme , tokenColorMap ) ;
261+ let colorMap = AbstractTextMateService . _toColorMap ( tokenColorMap ) ;
258262 let cssRules = generateTokensCSSForColorMap ( colorMap ) ;
259263 this . _styleElement . innerHTML = cssRules ;
260264 TokenizationRegistry . setColorMap ( colorMap ) ;
0 commit comments