Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Less distracting error message for JSON schema resolution issues #60219
Related issue: #51032
Instead of showing an error in the Problems tab, this PR changes the JSON Language Service to show a status bar icon if a JSON Schema cannot be resolved. This icon is hidden again once the current file is changed.
As suggested here by @aeschli, this adds a middleware that intercepts diagnostics from the server. If one of the diagnostics is a
Note: To test this, point
No tests are provided. This reason for this is that I was not able to find any tests for that particular module and adding entirely new ones seemed overkill for this issue.
I will squash the commits once I get feedback on whether the new dependency is desired and if further adjustments are needed.
Thanks a lot @xxyy !
There can be a hover on the status item explaining that validation for the current file is disabled as the schema could not be resolved.
I have changed the error code to use the magic value instead of the dependency. Also, I'm now using a custom status bar item to show the error, as suggested. (see the updated PR description for a screenshot) The item is only shown if a schema error occurred and hidden otherwise.
I have also added the retry action. Below the error message (I'll look into making a PR to make it nicer in vscode-json-languageservice later this week), a hint is shown that one may click to retry. When the retry command is received, the icon changes to a watch and the server is notified to re-verify the current file. It changes back or disappears when the server sends the resulting diagnostics.
Currently, I'm hiding the status bar item when the active editor is changed – it's not relevant in any other file. However, the issue is that diagnostics are not recomputed when switching tabs, so the icon will not reappear unless the JSON file is changed. Should I just keep the status bar icon when switching files? (might be annoying) If not, i'd have to re-verify the schema every time a JSON file is switched to. (If there's no way to have hidden diagnostics)
Also I'm unable to get the locale string from
I'd remember which open documents have scheme resolve errors so you can use this when an editor gets active.
Great work @xxyy !
yes, we should only show the warning when the corresponding editor has focus.
I suggest to have a map with URI to schema-resolve error, so when the editor gets active you use that.
I'm now caching the files with resolution errors. Also, I changed