microsoft / microsoft/vscode-json-languageservice
Order fileMatches from more specific to more generic
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 326
- Forks
- 145
- Avg merge
- 22h 10m
- Merged PRs (30d)
- 9
Description
I have a .github/workflows/site.yml file that matches multiple entries from schemastore catalog:
{
"name": "Ansible Playbook",
"description": "Ansible playbook files",
"fileMatch": [
"playbook.yml",
"playbook.yaml",
"site.yml",
"site.yaml",
"**/playbooks/*.yml",
"**/playbooks/*.yaml"
],
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json#/$defs/playbook"
}
and
{
"name": "GitHub Workflow",
"description": "YAML GitHub Workflow",
"fileMatch": [
"**/.github/workflows/*.yml",
"**/.github/workflows/*.yaml",
"**/.gitea/workflows/*.yml",
"**/.gitea/workflows/*.yaml",
"**/.forgejo/workflows/*.yml",
"**/.forgejo/workflows/*.yaml"
],
"url": "https://www.schemastore.org/github-workflow.json"
}
Unfortunately, actually, Ansible Playbook is selected, which generates lots of false warnings in the file.
Could it be possible to prioritize the selection of the schema according to the number of characters matched outside of wildcards?
This way the more specific fileMatch will be selected if more that one match.
For example in my case, .github/workflows/site.yml:
- matches 8 characters for
site.yml - matches 23 characters for
**/.github/workflows/*.yml, excluding characters matched by wildcards
The second one is more specific characters and should be preferred
This should fix most of the cases relatively easily
Regards
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the language service selects among matching schema fileMatch entries for .github/workflows/site.yml; compare the literal portions of the Ansible and GitHub Workflow patterns shown in the issue. Done when the more-specific GitHub Workflow schema is selected for this example and the behavior is covered by an appropriate regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, yaml
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100