JSON Schema (still) not applied for custom file extension
Describe the bug
This has been reported previously, in issues:
- https://github.com/redhat-developer/vscode-yaml/issues/747
- https://github.com/redhat-developer/vscode-yaml/issues/701
And was fixed in PR #714
However, I'm still experiencing the issue.
I believe I can spot the error:
When it adds the custom file extensions to the yamlSettings.fileExtensions array, it pushes the entire pattern. This pattern most often has an asterisk in it, like *.bu. It then checks to see if the extension is present in the fileMatch property of the schema. The problem is that it does an indexOf of the pattern on the fileMatch string, which means it includes the asterisk when looking at the file.
So, I think a solution would be to remove the asterisk before searching for it in the fileMatch properties.
However, I'm a bit confused as to why the test passes...
Expected Behavior
YAML schemas are applied on files with custom extensions if they are configured in the files.associations array to be associated with YAML.
Current Behavior
YAML schemas are not applied on files with custom extensions.
Steps to Reproduce
See referenced issues.
Environment
- [ ] Windows
- [x] Mac
- [ ] Linux
- [ ] other (please specify)
Is this the case when the fileExtension and the fileMatch are not identical? The string matching is too simple for that case and we should do a glob match.
I'm puzzled by the behavior here. If I've opened a file and:
- my editor tells yaml-language-server that the file is open, the language is YAML and the filename is foo.bar
- schemastore says that files named "*.bar" have schema XYZ
...then why isn't that enough to use that schema? Why is yaml-language-server filtering out schemastore FileMatch patterns based on trying to reason about file extensions, when LSP says it's up to the editor to decide whether a file is YAML?
Apart from the specific issues about globs etc, this scheme seems like it won't work when:
- I've just manually set the language to YAML in the editor (in the status bar in vscode, or
:set ft=yamlin vim, etc) - I'm using a non-VSCode editor (the
files.associationssetting is not specified in LSP, it's a VSCode-specific setting and other editors will not return anything).
yaml-language-server creates an index of schemas it needs to know about using files.associations. We could improve the behaviour by adding incremental indexing on didOpen.
Unfortunately, we are not staffed to test/implement the LSP on editors other than VSCode, so such oversights happen.
Is there any update on this issue? I see it was part of the 1.12 milestone but seems to have been a little lost.
I'd argue that it's quite a useful issue to fix, not only for our own use case but also for all the other uses of custom file extensions, most notably dotfiles.