@@ -545,11 +545,10 @@ function getSettings(): Settings {
545
545
}
546
546
} ;
547
547
548
- const collectSchemaSettings = ( schemaSettings : JSONSchemaSettings [ ] | undefined , folderUri ?: Uri ) => {
549
-
548
+ const collectSchemaSettings = ( schemaSettings : JSONSchemaSettings [ ] | undefined , folderUri : Uri | undefined = undefined , settingsLocation = folderUri ) => {
550
549
if ( schemaSettings ) {
551
550
for ( const setting of schemaSettings ) {
552
- const url = getSchemaId ( setting , folderUri ) ;
551
+ const url = getSchemaId ( setting , settingsLocation ) ;
553
552
if ( url ) {
554
553
const schemaSetting : JSONSchemaSettings = { url, fileMatch : setting . fileMatch , folderUri : folderUri ?. toString ( false ) , schema : setting . schema } ;
555
554
schemas . push ( schemaSetting ) ;
@@ -558,15 +557,19 @@ function getSettings(): Settings {
558
557
}
559
558
} ;
560
559
560
+ const folders = workspace . workspaceFolders ;
561
+
561
562
const schemaConfigInfo = workspace . getConfiguration ( 'json' , null ) . inspect < JSONSchemaSettings [ ] > ( 'schemas' ) ;
562
563
if ( schemaConfigInfo ) {
563
- if ( workspace . workspaceFile ) {
564
- collectSchemaSettings ( schemaConfigInfo . workspaceValue , workspace . workspaceFile ) ;
564
+ if ( schemaConfigInfo . workspaceValue && workspace . workspaceFile && folders && folders . length ) {
565
+ const settingsLocation = Uri . joinPath ( workspace . workspaceFile , '..' ) ;
566
+ for ( const folder of folders ) {
567
+ collectSchemaSettings ( schemaConfigInfo . workspaceValue , folder . uri , settingsLocation ) ;
568
+ }
565
569
}
566
570
collectSchemaSettings ( schemaConfigInfo . globalValue ) ;
567
571
}
568
572
569
- const folders = workspace . workspaceFolders ;
570
573
if ( folders ) {
571
574
for ( const folder of folders ) {
572
575
const schemaConfigInfo = workspace . getConfiguration ( 'json' , folder . uri ) . inspect < JSONSchemaSettings [ ] > ( 'schemas' ) ;
@@ -576,14 +579,14 @@ function getSettings(): Settings {
576
579
return settings ;
577
580
}
578
581
579
- function getSchemaId ( schema : JSONSchemaSettings , folderUri ?: Uri ) : string | undefined {
582
+ function getSchemaId ( schema : JSONSchemaSettings , settingsLocation ?: Uri ) : string | undefined {
580
583
let url = schema . url ;
581
584
if ( ! url ) {
582
585
if ( schema . schema ) {
583
586
url = schema . schema . id || `vscode://schemas/custom/${ encodeURIComponent ( hash ( schema . schema ) . toString ( 16 ) ) } ` ;
584
587
}
585
- } else if ( folderUri && ( url [ 0 ] === '.' || url [ 0 ] === '/' ) ) {
586
- url = Uri . joinPath ( folderUri , url ) . toString ( false ) ;
588
+ } else if ( settingsLocation && ( url [ 0 ] === '.' || url [ 0 ] === '/' ) ) {
589
+ url = Uri . joinPath ( settingsLocation , url ) . toString ( false ) ;
587
590
}
588
591
return url ;
589
592
}
0 commit comments