Code change:
Issue Type: <bBug</bI have a multi-root VSC workspace with three folders: A/ ./subfolderOfA In A/, there is a file and in there, there are the following settings: When I edit some file somewhere inside A/, it seems like this JSON schema file path is only properly resolved If I remove folders and from my multi-root workspace. Shouldn't this work? VS Code version: Code 1.56.2 (, 2021-05-12T17:13:13.157Z) OS version: WindowsNT x64 10.0. <details<summarySystem Info</summary </details<details<summaryExtensions (10)</summaryExtensionVersion ------ bracket-pair-colorizer-20.2.0 xml2.5.1 tortoise-svn0.1.1 python2020.9. vscode-pylance2021.5.3 jupyter2021.6. cpptools1.3.1 code-spell-checker1.10.2 open-in-browser2.0.0 vscodeintellicode1.2.14 </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
Hi Unfortunately, I am not familiar with your planning process but I wanted to ask if this bug will be solved in the near future?
Sorry, I don't know when I will find time for looking at this.
It's honestly quite a shame that this feature is missing. Unless you want to modify the json file structure to include the "$schema" property you are stuck having to open the given sub-folders directly which is a significant detrement to the DX when working in multi-root workspaces.
Hi Sorry to pick this up again but, according to the motto "New Year, New Luck", is there a chance to have this and fixed soon?
It seems like relative schema path resolution does not work on Windows, even when not in a multi-root workspace. Schemas always try to resolve in rather than the workspace folder. !
Note: relative path can not be used in user settings. But they should work in workspace files, where I could reproduce the problem, thanks !
Now on macOS, unfortunately it seems like json.schemas in the workspace settings are ignored. <img width="1605" alt="image" src="https://user-"Changing to something invalid does not result in any diagnostics being reported, either. However if I move into my user settings and change the schema path to be absolute, it works.
Now I get in the Problems view with the following setup: In a non-multi-root workspace:
I created a separate issue to investigate as the error comes from to the empty which is unrelated. If you remove the you should see that the - schema is used
To verify: clone open workspace look at the workspace settings: all files are associated with schema . Note that this is a relative path to the workspace file open both files and check that code completion gives back property . You can also click on the JSON language selector ( next to JSON in the status bar) to see the schema that is associated look at the folder setings: is associated with schema . Note that this is a relative path to the folder open both files files and check that code completion gives back property , but only when in folder1. You can also click on the JSON language selector ( next to JSON in the status bar) to see the schema that is associated
I tried to verify this using build but the schemas are not used. Here is what I see in the UI: <img width="706" alt="image" src="https://user-" please advise which build I should use for verification.
Looks like it is still not working on Windows due to to an URI encoding issue.
I tested as described in with VS Code 1.76.0 on Windows. I observed the following for and in VS Code: no schema-defined code completion is offered there is no schema offered when clicking on the language selector I then tested folder-only settings by opening VS Code to . I observed the same as above for . FWIW, describes another repro with only folder settings (not workspace settings). Is there a known workaround to get validation working using on Windows for 1.76.0?
the fix for Windows is coming:
is now also fixed (and verified)

Related discussion:
text: validate: { enable: configuration.get(SettingIds.enableValidation) }, format: { enable: configuration.get(SettingIds.enableFormatter) }, keepLines: { enable: configuration.get(SettingIds.enableKeepLines) }, <del> schemas: [], </del> <ins> schemas, </ins> resultLimit: resultLimit + 1, // ask for one more so we can detect if the limit has been exceeded jsonFoldingLimit: jsonFoldingLimit + 1, jsoncFoldingLimit: jsoncFoldingLimit + 1 } }; <del> const schemaSettingsById: { [schemaId: string]: JSONSchemaSettings } = Object.create(null); const collectSchemaSettings = (schemaSettings: JSONSchemaSettings[], folderUri?: Uri, isMultiRoot?: boolean) => { let fileMatchPrefix = undefined; if (folderUri && isMultiRoot) { fileMatchPrefix = folderUri.toString(); if (fileMatchPrefix[fileMatchPrefix.length - 1] === '/') { fileMatchPrefix = fileMatchPrefix.substr(0, fileMatchPrefix.length - 1); } } </del> <ins> const collectSchemaSettings = (schemaSettings: JSONSchemaSettings[], folderUri?: Uri) => { </ins> for (const setting of schemaSettings) { const url = getSchemaId(setting, folderUri); <del> if (!url) { continue; } let schemaSetting = schemaSettingsById[url]; if (!schemaSetting) { schemaSetting = schemaSettingsById[url] = { url, fileMatch: [] }; settings.json!.schemas!.push(schemaSetting); } const fileMatches = setting.fileMatch; if (Array.isArray(fileMatches)) { const resultingFileMatches = schemaSetting.fileMatch || []; schemaSetting.fileMatch = resultingFileMatches; const addMatch = (pattern: string) => { //  filter duplicates if (resultingFileMatches.indexOf(pattern) === -1) { resultingFileMatches.push(pattern); } }; for (const fileMatch of fileMatches) { if (fileMatchPrefix) { if (fileMatch[0] === '/') { addMatch(fileMatchPrefix + fileMatch); addMatch(fileMatchPrefix + '/*' + fileMatch); } else { addMatch(fileMatchPrefix + '/' + fileMatch); addMatch(fileMatchPrefix + '/*/' + fileMatch); } } else { addMatch(fileMatch); } } } if (setting.schema && !schemaSetting.schema) { schemaSetting.schema = setting.schema; </del> <ins> if (url) { const schemaSetting: JSONSchemaSettings = { url, fileMatch: setting.fileMatch, folderUri: folderUri?.toString(false), schema: setting.schema }; schemas.push(schemaSetting); </ins> } } }; <del> const folders = workspace.workspaceFolders; // merge global and folder settings. Qualify all file matches with the folder path. </del> const globalSettings = workspace.getConfiguration('json', null).get<JSONSchemaSettings[]>('schemas'); if (Array.isArray(globalSettings)) { <del> if (!folders) { collectSchemaSettings(globalSettings); } </del> <ins> collectSchemaSettings(globalSettings); </ins> } <ins> const folders = workspace.workspaceFolders; </ins> if (folders) { <del> const isMultiRoot = folders.length > 1; </del> for (const folder of folders) { <del> const folderUri = folder.uri; const schemaConfigInfo = workspace.getConfiguration('json', folderUri).inspect<JSONSchemaSettings[]>('schemas'); const folderSchemas = schemaConfigInfo!.workspaceFolderValue; if (Array.isArray(folderSchemas)) { collectSchemaSettings(folderSchemas, folderUri, isMultiRoot); </del> <ins> const schemaConfigInfo = workspace.getConfiguration('json', folder.uri).inspect<JSONSchemaSettings[]>('schemas'); if (schemaConfigInfo && Array.isArray(schemaConfigInfo.workspaceFolderValue)) { collectSchemaSettings(schemaConfigInfo.workspaceFolderValue, folder.uri); </ins> } <del> if (Array.isArray(globalSettings)) { collectSchemaSettings(globalSettings, folderUri, isMultiRoot); } </del> } } return settings;