@@ -577,9 +577,17 @@ export interface ILineSequence {
577577 getLineContent ( lineNumber : number ) : string ;
578578}
579579
580- class SemanticColoringFeature extends Disposable {
580+ export const SEMANTIC_HIGHLIGHTING_SETTING_ID = 'editor.semanticHighlighting' ;
581+
582+ export function isSemanticColoringEnabled ( model : ITextModel , themeService : IThemeService , configurationService : IConfigurationService ) : boolean {
583+ if ( ! themeService . getColorTheme ( ) . semanticHighlighting ) {
584+ return false ;
585+ }
586+ const options = configurationService . getValue < IEditorSemanticHighlightingOptions > ( SEMANTIC_HIGHLIGHTING_SETTING_ID , { overrideIdentifier : model . getLanguageIdentifier ( ) . language , resource : model . uri } ) ;
587+ return Boolean ( options && options . enabled ) ;
588+ }
581589
582- private static readonly SETTING_ID = 'editor.semanticHighlighting' ;
590+ class SemanticColoringFeature extends Disposable {
583591
584592 private readonly _watchers : Record < string , ModelSemanticColoring > ;
585593 private readonly _semanticStyling : SemanticStyling ;
@@ -589,13 +597,6 @@ class SemanticColoringFeature extends Disposable {
589597 this . _watchers = Object . create ( null ) ;
590598 this . _semanticStyling = semanticStyling ;
591599
592- const isSemanticColoringEnabled = ( model : ITextModel ) => {
593- if ( ! themeService . getColorTheme ( ) . semanticHighlighting ) {
594- return false ;
595- }
596- const options = configurationService . getValue < IEditorSemanticHighlightingOptions > ( SemanticColoringFeature . SETTING_ID , { overrideIdentifier : model . getLanguageIdentifier ( ) . language , resource : model . uri } ) ;
597- return options && options . enabled ;
598- } ;
599600 const register = ( model : ITextModel ) => {
600601 this . _watchers [ model . uri . toString ( ) ] = new ModelSemanticColoring ( model , themeService , this . _semanticStyling ) ;
601602 } ;
@@ -606,7 +607,7 @@ class SemanticColoringFeature extends Disposable {
606607 const handleSettingOrThemeChange = ( ) => {
607608 for ( let model of modelService . getModels ( ) ) {
608609 const curr = this . _watchers [ model . uri . toString ( ) ] ;
609- if ( isSemanticColoringEnabled ( model ) ) {
610+ if ( isSemanticColoringEnabled ( model , themeService , configurationService ) ) {
610611 if ( ! curr ) {
611612 register ( model ) ;
612613 }
@@ -618,7 +619,7 @@ class SemanticColoringFeature extends Disposable {
618619 }
619620 } ;
620621 this . _register ( modelService . onModelAdded ( ( model ) => {
621- if ( isSemanticColoringEnabled ( model ) ) {
622+ if ( isSemanticColoringEnabled ( model , themeService , configurationService ) ) {
622623 register ( model ) ;
623624 }
624625 } ) ) ;
@@ -629,7 +630,7 @@ class SemanticColoringFeature extends Disposable {
629630 }
630631 } ) ) ;
631632 this . _register ( configurationService . onDidChangeConfiguration ( e => {
632- if ( e . affectsConfiguration ( SemanticColoringFeature . SETTING_ID ) ) {
633+ if ( e . affectsConfiguration ( SEMANTIC_HIGHLIGHTING_SETTING_ID ) ) {
633634 handleSettingOrThemeChange ( ) ;
634635 }
635636 } ) ) ;
0 commit comments