Change:
Type: <bBug</bWhen attempting to exclude files from a generic *.json schema, VSCode doesn't seem to recognize that, and apply it anyway. VS Code version: Code 1.73.1 (, 2022-11-09T04:27:29.066Z) OS version: WindowsNT x64 10.0. Modes: Sandboxed: No Remote OS version: Linux arm64 5.15.0-1021-oracle <details<summarySystem Info</summary </details<details<summaryExtensions (33)</summaryExtensionVersion ------ 5et-homebrew-helper0.3.1 vscode-todo-highlight2.0.4 vscord5.0.10 dotenv1.0.1 jupyter-keymap1.0.0 remote-ssh0.92.0 remote-ssh-edit0.84.0 remote-explorer0.0.2 5e-syntax0.1.0 vscode-icons12.0.1 unity-snippets0.1.2 go-to-character-position2.0.0 vscode-eslint2.2.6 git-project-manager1.8.2 vscode-npm3.3.0 sort-json-array3.1.0 copilot1.61.7372 git-graph1.30.0 isort2022.8.0 python2022.18.2 vscode-pylance2022.11.30 jupyter2022.9. jupyter-keymap1.0.0 jupyter-renderers1.0.12 vscode-jupyter-cell-tags0.1.6 vscode-jupyter-slideshow0.1.5 vscode-json-editor0.3.0 vscode-yaml1.10.1 svelte-vscode106.2.0 pdf1.2.0 intellicode-api-usage-examples0.2.6 vscodeintellicode1.2.29 json2.0.2 (1 theme extensions excluded) </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
For example, this: Still tries to validate files and all files in the folder. The first schema that applies only to the folder is also, simultaneously applied with the others, while it should be the only one. is also under this effect.
Ok, I see the bug. It's because of , where we merge the schema associations
Also affecting myself
The workaround is not use two file associations for the same schema. Just write:
This unfortunately simply breaks the validation. The two fileMatches are required for VSCode to detect the files. Not sure why doesn't catch everything.
To elaborate https://user-

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"