@@ -629,7 +629,9 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
629
629
public readonly onDidChangeConfiguration = this . _onDidChangeConfiguration . event ;
630
630
631
631
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
633
635
) {
634
636
this . configurationService . onDidChangeConfiguration ( ( e ) => {
635
637
this . _onDidChangeConfiguration . fire ( { affectedKeys : e . affectedKeys , affectsConfiguration : ( resource : URI , configuration : string ) => e . affectsConfiguration ( configuration ) } ) ;
@@ -638,13 +640,28 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
638
640
639
641
getValue < T > ( resource : URI , section ?: string ) : T ;
640
642
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 ) {
642
644
const position : IPosition | null = Pos . isIPosition ( arg2 ) ? arg2 : null ;
643
645
const section : string | undefined = position ? ( typeof arg3 === 'string' ? arg3 : undefined ) : ( typeof arg2 === 'string' ? arg2 : undefined ) ;
646
+ const language = resource ? this . getLanguage ( resource , position ) : undefined ;
644
647
if ( typeof section === 'undefined' ) {
645
- return this . configurationService . getValue < T > ( ) ;
648
+ return this . configurationService . getValue < T > ( {
649
+ resource,
650
+ overrideIdentifier : language
651
+ } ) ;
646
652
}
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 ) ;
648
665
}
649
666
650
667
updateValue ( resource : URI , key : string , value : any , configurationTarget ?: ConfigurationTarget ) : Promise < void > {
0 commit comments