Files
soreavis d4b0f3a68e JSON - support ${workspaceFolder} in json.schemas fileMatch patterns (#326706)
* JSON - support ${workspaceFolder} in json.schemas fileMatch patterns

A fileMatch pattern has no way to target files in the workspace folder
root only: patterns are matched against the full document uri with an
implicit '**/' prefix, so `*.json` matches at every depth and a leading
`/` is redundant.

Expand a leading `${workspaceFolder}` (also after a `!` exclusion
prefix) to the workspace folder uri when collecting json.schemas
settings, in the two scopes with an unambiguous folder: workspace
folder settings in a multi-root workspace and workspace settings of a
single folder workspace. The expanded pattern is absolute, so the
implicit '**/' prefix no longer widens it and
`${workspaceFolder}/*.json` matches in the folder root only. The
server API stays unchanged.

Fixes #44135

* JSON - escape glob metacharacters when expanding ${workspaceFolder}

The service's glob has no escape syntax, so a folder name containing a
glob metacharacter altered the meaning of the expanded pattern: names
with brackets or braces made it match nothing and a '*' made it match
too much. Since the glob passes a backslash and alphanumerics through
to the resulting regular expression verbatim, encoding the folder
string's metacharacters as regex hex escapes makes them match
literally.

Also drop the query and fragment from the folder uri, mirroring what
the server does to document uris before matching.

* JSON - use startsWith to detect the ${workspaceFolder} prefix

* JSON - expand ${workspaceFolder} to the folder path

* JSON - move the glob escaping to a strings util

* JSON - percent-encode # and ? when expanding ${workspaceFolder}
2026-09-30 16:25:10 +02:00
..