Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[json] schema fileMatch for all *.json files in root folder #44135

Open
stkb opened this issue Feb 21, 2018 · 4 comments
Open

[json] schema fileMatch for all *.json files in root folder #44135

stkb opened this issue Feb 21, 2018 · 4 comments
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities json JSON support issues
Milestone

Comments

@stkb
Copy link
Contributor

stkb commented Feb 21, 2018

  • VSCode Version: 1.20.1
  • OS Version: Win 10
    Does this issue occur when all extensions are disabled?: Yes

I've tried asking this on stackoverflow and gitter without success. I have a project with (among other things) lots of .json files. This is the .vscode/settings.json file:

{
    "json.schemas": [
        {
            "fileMatch": [
                "*.json"
            ],
            "url": "https://path/to/schema.json"
        }
    ]
}

The problem is that this matches all .json files in the project, but I need it to match only *.json files in the root directory. What can I put in fileMatch to enable this, or can this not be done with the file matching?

@vscodebot vscodebot bot added the json JSON support issues label Feb 21, 2018
@RMacfarlane
Copy link
Contributor

Does "./*.json" work?

@stkb
Copy link
Contributor Author

stkb commented Feb 21, 2018

Unfortunately not, and btw I had it slightly wrong in my first post (now edited)

  • "*.json" matches all .json file in all directories.
  • "/*.json" matches only .json files 1+ levels down
  • "./*.json" doesn't seem to match any files.

@aeschli aeschli added the bug Issue identified by VS Code Team member as probable bug label Mar 1, 2018
@aeschli aeschli added this to the March 2018 milestone Mar 1, 2018
@aeschli aeschli modified the milestones: March 2018, April 2018 Mar 27, 2018
@aeschli aeschli modified the milestones: April 2018, May 2018 Apr 18, 2018
@aeschli aeschli modified the milestones: May 2018, June 2018 May 29, 2018
@aeschli
Copy link
Contributor

aeschli commented Jun 25, 2018

The patterns currently just match against the end of the full file path. The matcher is not aware of the workspace folder.
A workaround for you is to add the name of the root folder to the pattern, e.g. myroot/*.json, but of course, that's not ideal.

We would need something like a `${workspaceFolder} variable to do this properly.

@aeschli aeschli modified the milestones: June 2018, Backlog Jun 25, 2018
@aeschli aeschli added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug labels Jun 25, 2018
@aeschli aeschli changed the title Json schema fileMatch for all *.json files in root folder [json] schema fileMatch for all *.json files in root folder Sep 21, 2018
@coodeneko
Copy link

I'm getting a similar problem. The * in folder/*.json matches against sub-folders as well such as folder/child/file.json instead of just the current directly. Would it be possible to split * for just file pattern matching and ** for folder and file pattern matching similar to other implementations of file pattern matching such as glob?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities json JSON support issues
Projects
None yet
Development

No branches or pull requests

4 participants