-
Notifications
You must be signed in to change notification settings - Fork 190
Improve the "trailing-comma" regex #383
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
Conversation
|
Here is the relevant spec: https://spec.json5.org/#white-space. |
|
Note also "any other character in the unicode whitespace category". |
|
The regex for
If just |
Ahaaaa.... ok - figured it out partially. It's definitely context-dependent. I happened to be in I'll update to remove the gratuitous
I'm hesitant to try hand-coding ranges for unicode. It looks like both |
f297db4 to
6056c84
Compare
|
Okay... Lesson learned - I should have RTFM, :P
|
|
So |
|
Btw, the |
|
@kiennq I see you accepted... are you able to merge? |
|
@jrwats thank you! |
The old regex was missing a significant number of legitimate spaces per the JSON spec: https://spec.json5.org/#white-space. In effect this meant, we wouldn't strip trailing commas that were followed by these valid characters. Make the regex exhaustive.
I'm sprinkling all the relevant space characters in the tests as defined by the spec to ensure our regex catches them all.
NOTE: if you try manually testing
dap-launch-sanitize-jsoninjson-modeorjs-mode, you're gonna have a bad time. Test this stuff infundamental-modeif you find yourself so inclined...