Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.66.2 (Tested in Insiders 1.67.0 with same results) OS Version: Windows 10 Education N x64 - 21H1 Steps to Reproduce: a Workspace and add a simple folder with a schema for JSON files defined in the folder settings. ! <details<summaryschema-</summary</detailsthat the file is being validated correctly. ! a second folder to the workspace. In my test I an empty folder in the same root as the workspace. The validation still works as expected. the window or close/open VSCode. The schema validation has stopped working as if the file did not match the in the folder settings. Removing the second folder and reloading makes it work again. ! As a note, if you open directly in VSCode rather than the workspace, the validation works as expected.
The new validated by schema information is great. But this reported issue in work spaces prevents me from upgrading from 1.65. Any chance this will be addressed anytime soon?
Is it working correctly pre-1.65? Because this issue is very annoying here (we have to open multiple instances of vscode as workaround which is problematic for various reasons), and we could very much just ship a portable version of previous version of vscode
Yes it worked before. So you should be good with an old release for the time being. Not a solution but at least workspaces are usable.
Update: Not fixed. Just tried in 1.73-insiders and still happening
Still have the bug on 1.71 on my machine. Top: Workspace, Bottom: Folder !
Still have the bug on 1.71.2
I'm on 1.73 and this is still an issue. Works ok when you open a folder and the json.schemas is at the root of it inside .vscode folder. It doesn't work in a multi-root workspace. We have a lot of JSON files and autocomplete doesn't work anymore. This used to work before. Surprised as to why this is not getting any traction. Seems like a huge regression in functionality.
I noticed this is OS-specific too. On ubuntu 22 machine multi-root validation works fine but on windows 10 machine it doesn't, on the same codebase.
Yeah, this is probably the reason I tricked myself it was working back then. , any status update on this? I am pinging, because there has been no update on the matter since its original report in April, and the issue is 100% reproducible on any vscode version since 1.65
Can confirm this observation, the issue only occurs in windows and not on Ubuntu, have not tested macOS
Same here using Remote-SSH to an Ubuntu workspace.
Same here using Remote-SSH to a Redhat workspace. However, it works right setting the "$schema": "url-schema" attribute in the .json file.

Discussion:
fileMatch?: string[]; url?: string; schema?: any; <ins> folderUri?: string; </ins> }; export namespace SettingIds {

jsonFoldingLimit = normalizeLimit(workspace.getConfiguration(SettingIds.editorSection, { languageId: 'json' }).get(SettingIds.foldingMaximumRegions)); jsoncFoldingLimit = normalizeLimit(workspace.getConfiguration(SettingIds.editorSection, { languageId: 'jsonc' }).get(SettingIds.foldingMaximumRegions)); <ins> const schemas: JSONSchemaSettings[] = []; </ins> const settings: Settings = { http: { proxy: httpSettings.get('proxy'),

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;

url = schema.schema.id || `vscode://schemas/custom/${encodeURIComponent(hash(schema.schema).toString(16))}`; } } else if (folderUri && (url[0] === '.' || url[0] === '/')) { <del> url = Uri.joinPath(folderUri, url).toString(); </del> <ins> url = Uri.joinPath(folderUri, url).toString(false); </ins> } return url; }

- `schemas`: Configures association of file names to schema URL or schemas and/or associations of schema URL to schema content. - `fileMatch`: an array of file names or paths (separated by `/`). `*` can be used as a wildcard. Exclusion patterns can also be defined and start with '!'. A file matches when there is at least one matching pattern and the last matching pattern is not an exclusion pattern. - `url`: The URL of the schema, optional when also a schema is provided. <del> - `schema`: The schema content. </del> <ins> - `schema`: The schema content, optional - `folderUri`: If provided, the association is only used if the document is located in the given folder (directly or indirectly) </ins> - `resultLimit`: The max number of color decorators and outline symbols to be computed (for performance reasons) - `jsonFoldingLimit`: The max number of folding ranges to be computed for json documents (for performance reasons) - `jsoncFoldingLimit`: The max number of folding ranges to be computed for jsonc documents (for performance reasons)

* A match succeeds when there is at least one pattern matching and last matching pattern does not start with '!'. */ fileMatch: string[]; <ins> /** * If provided, the association is only used if the validated document is located in the given folder (directly or indirectly) */ folderUri?: string; </ins> /* * The schema for the given URI. * If no schema is provided, the schema will be fetched with the schema request service (if available).

}, "main": "./out/node/jsonServerMain", "dependencies": { <ins> "@vscode/l10n": "^0.0.11", </ins> "jsonc-parser": "^3.2.0", "request-light": "^0.7.0", <del> "vscode-json-languageservice": "^5.1.4", </del> <ins> "vscode-json-languageservice": "^5.2.0", </ins> "vscode-languageserver": "^8.1.0-next.6", <del> "vscode-uri": "^3.0.7", "@vscode/l10n": "^0.0.11" </del> <ins> "vscode-uri": "^3.0.7" </ins> }, "devDependencies": { "@types/mocha": "^9.1.1",

fileMatch?: string[]; url?: string; schema?: JSONSchema; <ins> folderUri?: string; </ins> }

uri = schema.schema.id || `vscode://schemas/custom/${index}`; } if (uri) { <del> languageSettings.schemas.push({ uri, fileMatch: schema.fileMatch, schema: schema.schema }); </del> <ins> languageSettings.schemas.push({ uri, fileMatch: schema.fileMatch, schema: schema.schema, folderUri: schema.folderUri }); </ins> } }); }

resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.7.0.tgz#885628bb2f8040c26401ebf258ec51c4ae98ac2a" integrity sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q== <del> vscode-json-languageservice@^5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-5.1.4.tgz#cbdb447f281dcd107705e7fe8fbfc0b71db7610d" integrity sha512-ROZ1ezYQUbq9b/07xYpHtZSyyhoUk3oTTGVAEr6bU1DKr8ELaz9fsDoHno34tKtHj/Tf3deQqfjQNGKdbRuvTw== </del> <ins> vscode-json-languageservice@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-5.2.0.tgz#884b7f108be4310e3332167c3ea60ab17f03418c" integrity sha512-q8Rdhu2HEddRxvlhVqwh0cWmKK+OtyMB2xRhtqXEQ7cjb0iZ14madb90iJe9fCHPjoj9CGBrq6QzuOp8OE6XWg== </ins> dependencies: "@vscode/l10n" "^0.0.11" jsonc-parser "^3.2.0"