@@ -596,7 +596,9 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
596
596
public readonly onDidChangeConfiguration = this . _onDidChangeConfiguration . event ;
597
597
598
598
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
600
602
) {
601
603
this . configurationService . onDidChangeConfiguration ( ( e ) => {
602
604
this . _onDidChangeConfiguration . fire ( { affectedKeys : e . affectedKeys , affectsConfiguration : ( resource : URI , configuration : string ) => e . affectsConfiguration ( configuration ) } ) ;
@@ -605,13 +607,28 @@ class StandaloneResourceConfigurationService implements ITextResourceConfigurati
605
607
606
608
getValue < T > ( resource : URI , section ?: string ) : T ;
607
609
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 ) {
609
611
const position : IPosition | null = Pos . isIPosition ( arg2 ) ? arg2 : null ;
610
612
const section : string | undefined = position ? ( typeof arg3 === 'string' ? arg3 : undefined ) : ( typeof arg2 === 'string' ? arg2 : undefined ) ;
613
+ const language = resource ? this . getLanguage ( resource , position ) : undefined ;
611
614
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 ( ) ;
613
630
}
614
- return this . configurationService . getValue < T > ( section ) ;
631
+ return this . languageService . guessLanguageIdByFilepathOrFirstLine ( resource ) ;
615
632
}
616
633
617
634
updateValue ( resource : URI , key : string , value : any , configurationTarget ?: ConfigurationTarget ) : Promise < void > {
0 commit comments