@@ -47,33 +47,42 @@ type ConfigurationInspect<T> = {
4747 workspaceFolderLanguageValue ?: T ;
4848} ;
4949
50- function isWorkspaceFolder ( thing : any ) : thing is vscode . WorkspaceFolder {
50+ function isUri ( thing : any ) : thing is vscode . Uri {
51+ return thing instanceof URI ;
52+ }
53+
54+ function isResourceLanguage ( thing : any ) : thing is { uri : URI , languageId : string } {
5155 return thing
5256 && thing . uri instanceof URI
53- && ( ! thing . name || typeof thing . name === 'string' )
54- && ( ! thing . index || typeof thing . index === 'number' ) ;
57+ && ( thing . languageId && typeof thing . languageId === 'string' ) ;
5558}
5659
57- function isUri ( thing : any ) : thing is vscode . Uri {
58- return thing instanceof URI ;
60+ function isLanguage ( thing : any ) : thing is { languageId : string } {
61+ return thing
62+ && ! thing . uri
63+ && ( thing . languageId && typeof thing . languageId === 'string' ) ;
5964}
6065
61- function isResourceLanguage ( thing : any ) : thing is { uri : URI , languageId : string } {
66+ function isWorkspaceFolder ( thing : any ) : thing is vscode . WorkspaceFolder {
6267 return thing
6368 && thing . uri instanceof URI
64- && ( ! thing . languageId || typeof thing . languageId === 'string' ) ;
69+ && ( ! thing . name || typeof thing . name === 'string' )
70+ && ( ! thing . index || typeof thing . index === 'number' ) ;
6571}
6672
6773function scopeToOverrides ( scope : vscode . ConfigurationScope | undefined | null ) : IConfigurationOverrides | undefined {
6874 if ( isUri ( scope ) ) {
6975 return { resource : scope } ;
7076 }
71- if ( isWorkspaceFolder ( scope ) ) {
72- return { resource : scope . uri } ;
73- }
7477 if ( isResourceLanguage ( scope ) ) {
7578 return { resource : scope . uri , overrideIdentifier : scope . languageId } ;
7679 }
80+ if ( isLanguage ( scope ) ) {
81+ return { overrideIdentifier : scope . languageId } ;
82+ }
83+ if ( isWorkspaceFolder ( scope ) ) {
84+ return { resource : scope . uri } ;
85+ }
7786 return undefined ;
7887}
7988
0 commit comments