Skip to content

Commit 400fde0

Browse files
authored
relative schema path not resolved properly (microsoft#175185)
1 parent 1fa08d1 commit 400fde0

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

extensions/json-language-features/client/src/jsonClient.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -545,27 +545,32 @@ function getSettings(): Settings {
545545
}
546546
};
547547

548-
const collectSchemaSettings = (schemaSettings: JSONSchemaSettings[], folderUri?: Uri) => {
549-
for (const setting of schemaSettings) {
550-
const url = getSchemaId(setting, folderUri);
551-
if (url) {
552-
const schemaSetting: JSONSchemaSettings = { url, fileMatch: setting.fileMatch, folderUri: folderUri?.toString(false), schema: setting.schema };
553-
schemas.push(schemaSetting);
548+
const collectSchemaSettings = (schemaSettings: JSONSchemaSettings[] | undefined, folderUri?: Uri) => {
549+
550+
if (schemaSettings) {
551+
for (const setting of schemaSettings) {
552+
const url = getSchemaId(setting, folderUri);
553+
if (url) {
554+
const schemaSetting: JSONSchemaSettings = { url, fileMatch: setting.fileMatch, folderUri: folderUri?.toString(false), schema: setting.schema };
555+
schemas.push(schemaSetting);
556+
}
554557
}
555558
}
556559
};
557560

558-
const globalSettings = workspace.getConfiguration('json', null).get<JSONSchemaSettings[]>('schemas');
559-
if (Array.isArray(globalSettings)) {
560-
collectSchemaSettings(globalSettings);
561+
const schemaConfigInfo = workspace.getConfiguration('json', null).inspect<JSONSchemaSettings[]>('schemas');
562+
if (schemaConfigInfo) {
563+
if (workspace.workspaceFile) {
564+
collectSchemaSettings(schemaConfigInfo.workspaceValue, workspace.workspaceFile);
565+
}
566+
collectSchemaSettings(schemaConfigInfo.globalValue);
561567
}
568+
562569
const folders = workspace.workspaceFolders;
563570
if (folders) {
564571
for (const folder of folders) {
565572
const schemaConfigInfo = workspace.getConfiguration('json', folder.uri).inspect<JSONSchemaSettings[]>('schemas');
566-
if (schemaConfigInfo && Array.isArray(schemaConfigInfo.workspaceFolderValue)) {
567-
collectSchemaSettings(schemaConfigInfo.workspaceFolderValue, folder.uri);
568-
}
573+
collectSchemaSettings(schemaConfigInfo?.workspaceFolderValue, folder.uri);
569574
}
570575
}
571576
return settings;

0 commit comments

Comments
 (0)