@@ -596,7 +596,9 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
596596 public readonly onDidChangeConfiguration = this . _onDidChangeConfiguration . event ;
597597
598598 constructor (
599- @IConfigurationService private readonly configurationService : StandaloneConfigurationService
599+ @IConfigurationService private readonly configurationService : StandaloneConfigurationService ,
600+ @IModelService private readonly modelService : IModelService ,
601+ @ILanguageService private readonly languageService : ILanguageService
600602 ) {
601603 this . configurationService . onDidChangeConfiguration ( ( e ) => {
602604 this . _onDidChangeConfiguration . fire ( { affectedKeys : e . affectedKeys , affectsConfiguration : ( resource : URI , configuration : string ) => e . affectsConfiguration ( configuration ) } ) ;
@@ -605,13 +607,28 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
605607
606608 getValue < T > ( resource : URI , section ?: string ) : T ;
607609 getValue < T > ( resource : URI , position ?: IPosition , section ?: string ) : T ;
608- getValue < T > ( resource : any , arg2 ?: any , arg3 ?: any ) {
610+ getValue < T > ( resource : URI | undefined , arg2 ?: any , arg3 ?: any ) {
609611 const position : IPosition | null = Pos . isIPosition ( arg2 ) ? arg2 : null ;
610612 const section : string | undefined = position ? ( typeof arg3 === 'string' ? arg3 : undefined ) : ( typeof arg2 === 'string' ? arg2 : undefined ) ;
613+ const language = resource ? this . getLanguage ( resource , position ) : undefined ;
611614 if ( typeof section === 'undefined' ) {
612- return this . configurationService . getValue < T > ( ) ;
615+ return this . configurationService . getValue < T > ( {
616+ resource,
617+ overrideIdentifier : language
618+ } ) ;
619+ }
620+ return this . configurationService . getValue < T > ( section , {
621+ resource,
622+ overrideIdentifier : language
623+ } ) ;
624+ }
625+
626+ private getLanguage ( resource : URI , position : IPosition | null ) : string | null {
627+ const model = this . modelService . getModel ( resource ) ;
628+ if ( model ) {
629+ return position ? model . getLanguageIdAtPosition ( position . lineNumber , position . column ) : model . getLanguageId ( ) ;
613630 }
614- return this . configurationService . getValue < T > ( section ) ;
631+ return this . languageService . guessLanguageIdByFilepathOrFirstLine ( resource ) ;
615632 }
616633
617634 updateValue ( resource : URI , key : string , value : any , configurationTarget ?: ConfigurationTarget ) : Promise < void > {
0 commit comments