@@ -629,7 +629,9 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
629629 public readonly onDidChangeConfiguration = this . _onDidChangeConfiguration . event ;
630630
631631 constructor (
632- @IConfigurationService private readonly configurationService : StandaloneConfigurationService
632+ @IConfigurationService private readonly configurationService : StandaloneConfigurationService ,
633+ @IModelService private readonly modelService : IModelService ,
634+ @ILanguageService private readonly languageService : ILanguageService
633635 ) {
634636 this . configurationService . onDidChangeConfiguration ( ( e ) => {
635637 this . _onDidChangeConfiguration . fire ( { affectedKeys : e . affectedKeys , affectsConfiguration : ( resource : URI , configuration : string ) => e . affectsConfiguration ( configuration ) } ) ;
@@ -638,13 +640,28 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
638640
639641 getValue < T > ( resource : URI , section ?: string ) : T ;
640642 getValue < T > ( resource : URI , position ?: IPosition , section ?: string ) : T ;
641- getValue < T > ( resource : any , arg2 ?: any , arg3 ?: any ) {
643+ getValue < T > ( resource : URI | undefined , arg2 ?: any , arg3 ?: any ) {
642644 const position : IPosition | null = Pos . isIPosition ( arg2 ) ? arg2 : null ;
643645 const section : string | undefined = position ? ( typeof arg3 === 'string' ? arg3 : undefined ) : ( typeof arg2 === 'string' ? arg2 : undefined ) ;
646+ const language = resource ? this . getLanguage ( resource , position ) : undefined ;
644647 if ( typeof section === 'undefined' ) {
645- return this . configurationService . getValue < T > ( ) ;
648+ return this . configurationService . getValue < T > ( {
649+ resource,
650+ overrideIdentifier : language
651+ } ) ;
646652 }
647- return this . configurationService . getValue < T > ( section ) ;
653+ return this . configurationService . getValue < T > ( section , {
654+ resource,
655+ overrideIdentifier : language
656+ } ) ;
657+ }
658+
659+ private getLanguage ( resource : URI , position : IPosition | null ) : string | null {
660+ const model = this . modelService . getModel ( resource ) ;
661+ if ( model ) {
662+ return position ? model . getLanguageIdAtPosition ( position . lineNumber , position . column ) : model . getLanguageId ( ) ;
663+ }
664+ return this . languageService . guessLanguageIdByFilepathOrFirstLine ( resource ) ;
648665 }
649666
650667 updateValue ( resource : URI , key : string , value : any , configurationTarget ?: ConfigurationTarget ) : Promise < void > {
0 commit comments