weixin_39761481
weixin_39761481
2020-12-08 21:06

fix: dont trigger errors on vscode json files

fixes #81

By default, jsonc-parser doesn't allow trailing commas

I also took the liberty of improving the error message shown to the user to show that it's from this extension (the change in src/util), since i had to go through extensions and disable them to figure out that it was this extension.

该提问来源于开源项目:42Crunch/vscode-openapi

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39525118 weixin_39525118 5月前

    CLA assistant check
    All committers have signed the CLA.

    点赞 评论 复制链接分享
  • weixin_39761481 weixin_39761481 5月前

    also, note that i have NOT tested this at all. i just looked at the code and was like "well there's your problem" and fixed it. although it does pass tsc build, so that's something.

    点赞 评论 复制链接分享
  • weixin_39534978 weixin_39534978 5月前

    VS Code also enables allowEmptyContent: https://github.com/microsoft/vscode/blob/39f8e2a1dc659ada453d0980e945b557e5bf817a/src/vs/workbench/services/configuration/common/jsonEditingService.ts#L102, otherwise it errors on empty JSON files.

    We should consider not showing JSON parse errors at all, as the builtin JSON extension is already going to show them and it shows them better and localized: https://github.com/microsoft/vscode/blob/f74e473238aca7b79c08be761d99a0232838ca4c/src/vs/base/common/jsonErrorMessages.ts. If this extension also shows them, they just end up duplicated.

    P.S. VS Code seems to default source of the diagnostic to openapi on my end without having to set something on the diagnostic.

    点赞 评论 复制链接分享
  • weixin_39977488 weixin_39977488 5月前

    Thanks for your contribution! I'm merging the PR, changes will be available in the next release. Thanks for your comments as well, I'll consider the points you've raised.

    点赞 评论 复制链接分享

相关推荐