Quick changes to support array item validation #142
+1,047
−2,175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Not sure whether this contribution will be appreciated (and I totally won't be offended if it isn't), but I wanted syntax highlighting on individual (non-object) array items to work (plus to change some linting behavior to mirror VSCode a bit more closer, for ex. missing required properties highlighting the key) and I'd already done a bit of poking around the code to patch away the use of
shikijs
(my specific use-case makes it a bit less straight-forward to use things which require WASM), and had plans to make changes to autocomplete... so I just figured what the heck, may as well make a fork.Rather than hoard my changes I thought I'd share them in case they're at all useful to the project. Admittedly, I haven't thoroughly tested them (beyond passing tests), so I'm open to making some edits if it turns out to have been an incorrect approach, but so far it seems to work for my needs.
This PR extends the existing
getJsonPointers()
code to add support for registering pointers to non-object array items, returning most specific error paths (when possible), and updates existing tests to reflect the changes. It also updateskeyFrom
andkeyTo
to be optional, to allow root objects and array elements to not have a key range (which makes sense to me), only a value range.