redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.1k stars 264 forks source link

Local YAML schema applied to itself #871

Closed odiak closed 1 year ago

odiak commented 1 year ago

Describe the bug

Related to https://github.com/redhat-developer/vscode-yaml/issues/894.

I'm using YAML VSCode extension. I wrote a custom YAML schema in a project and associate its schema to some files in the project using VSCode setting like below.

// .vscode/settings.json
// ...
  "yaml.schemas": {
    "./schemas/custom.yml": [ "./a/config.yml", "./b/config.yml" ]
  }
// ...

Though ./schemas/custom.yml is applied to ./{a,b}/config.yml, but it is also applied to ./schemas/custom.yml itself.

Expected Behavior

The schema ./schemas/custom.yml is NOT applied to schemas/custom.yml itself.

Current Behavior

The schema ./schemas/custom.yml is NOT applied to schemas/custom.yml itself.

Steps to Reproduce

  1. Open a project in VSCode (YAML extension was installed)
  2. Write custom YAML schema schemas/custom.yml
  3. Associate the schema to some files by "yaml.schemas" setting in .vscode/settings.json

Environment

odiak commented 1 year ago

I roughly read source code, and I thought code below might cause this issue.

https://github.com/redhat-developer/yaml-language-server/blob/cf3f79202524ba979f1f4011636b85d08d81bdcb/src/languageservice/services/yamlSchemaService.ts#L408-L417

This was introduced in pull request: https://github.com/redhat-developer/yaml-language-server/pull/282

odiak commented 1 year ago

@JPinkney As original author of that code, how do you think of this problem?