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

Relative path schema loading #154

Closed
Vidminas opened this issue Jun 12, 2019 · 5 comments · Fixed by #156
Closed

Relative path schema loading #154

Vidminas opened this issue Jun 12, 2019 · 5 comments · Fixed by #156

Comments

@Vidminas
Copy link
Contributor

With a custom schema configuration in the workspace, such as

"yaml.schemas" : {
      "./json_schema/my_schema.json" : "/*.yaml"
    }

The schema fails to load with the output message:

[Error - 2:17:09 PM] Notification handler 'workspace/didChangeConfiguration' failed with message: [UriError]: Scheme is missing: {scheme: "", authority: "", path: "./json_schema/my_schema.json", query: "", fragment: ""}

This does not happen with the npm v0.4.1 yaml-language-server package, only with the latest GitHub build

@JPinkney
Copy link
Contributor

Hmm, I'm guessing you created a *.vsix file with master of YAML language server and master of VSCode-YAML? Or are you using a different editor?

If yes, is this commit in the vsix?

@Vidminas
Copy link
Contributor Author

That's pretty much it. Indeed, I have the latest commit in my working tree, so the commit you mention is included.

I've found that the error is caused by this call in connection.onDidChangeConfiguration:

jsonLanguageService.configure({
        schemas: jsonSchemas,
        validate: settings.yaml.validate,
        allowComments: true
    });

when jsonSchemas contains relative paths.

I think the trouble might have been introduced by this commit, specifically by the changes to onDidChangeConfiguration.

@Vidminas
Copy link
Contributor Author

The last commit fixes the errors, but there might some underlying issues with autocomplete. For my YAML files, auto completion is not giving any suggestions (although hovering works).
No issues with the npm server version 🤔

@JPinkney
Copy link
Contributor

Is it possible for you to post the schema? Its probably an issue inside of the autocompletor somewhere or when the schema is set. Autocompletion is the only feature we don't use https://www.npmjs.com/package/vscode-json-languageservice for

@Vidminas
Copy link
Contributor Author

Looks like this issue was being caused by my schema. The relative path loading patch should be enough to fix the schema loading errors.

The fact that my schema was the culprit, revealed another issue - even though I had fixed the schema in the editor, the schema content was not reloaded after it was changed on disk. Only after closing and re-opening VS Code did the changes take effect.
I found that registerExternalSchema in jsonSchemaService.ts gets the URI: file:///Users/vidminas/dev/yaml-langservice/test-workspace/json_schema/my_schema.json
but when the schema is edited, connection.onDidChangeWatchedFiles in server.ts gets the URI: file:///c%3A/Users/vidminas/dev/yaml-langservice/test-workspace/json_schema/my_schema.json

This c%3A is the encoded prefix C:, so this issue would only affect Windows.
Changing deprecated rootPath to rootUri param fixes this inconsistency.

But this still was not enough, now schema changes were picked up, but content was still not reloaded.
Turns out that a call to jsonLanguageService.resetSchema() was missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants