redhat-developer / vscode-yaml

YAML support for VS Code with built-in kubernetes syntax support
MIT License
669 stars 224 forks source link

Multiple JSON Schemas - Selection of single Schema not working #983

Open BlockyTheDev opened 1 year ago

BlockyTheDev commented 1 year ago

Describe the bug

It is not possible to select one JSON schema of the list, if multiple are detected for a specific file.

Detected Schemas: https://github.com/SchemaStore/schemastore/blob/404ada34125022391ae5a4484d490f3d769a6555/src/schemas/json/bungee-plugin.json https://github.com/SchemaStore/schemastore/blob/404ada34125022391ae5a4484d490f3d769a6555/src/schemas/json/bukkit-plugin.json https://github.com/SchemaStore/schemastore/blob/404ada34125022391ae5a4484d490f3d769a6555/src/schemas/json/pocketmine-plugin.json

Expected Behavior

The selection should work without problems.

Current Behavior

This VSCode extension is detecting three schemas for the same file, what is is right due to the same file name... of the file. In the right lower corner it shows "Multiple JSON Schemas...", when I click on this, a menu opens with the title "Select JSON schema", but when I'm going to select one out of the list nothing is happening. Still the same selection of all three files.

Steps to Reproduce

  1. Create a file named plugin.yml
  2. Click the button "Multiple JSON Schemas..."
  3. Select one, for example "Bukkit plugin.yml"
  4. Look at the button and see, that the button didn't change and the selection is still the same.

Environment

confiq commented 11 months ago

Thank you for this ticket.

I've fixed by editing .vscode/settings.json file

ephb commented 10 months ago

I have also encountered this. Where would the information about what the current schema is be stored?

yaroslavsadin commented 9 months ago

+1, can't select single JSON schema

UnePierre commented 8 months ago

+1

From what I can see, if one selects a JSON Schema by hand, the mapping of schema-path onto filename is added to the list yaml.schemas in settings.json -- irrespective of a previous match.

It doesn't matter, whether the previous match is via wildcard, or relative file name: an absolute-pathed entry is added. ⇒ Multiple entries match and the error is shown.

I think, this could be healed, if

  1. the relative entries would be matched and modified / replaced,
  2. there was an option to set schema paths relative to a variable, but there isn't.^1

So far, what works best for me is: