Allow graceful matching by parameter and repair null values matching #1048
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.
What does this PR do?
Allows passing a
gracefulMatches
parameter to the completion handler so that if any sub schema has at least one property value that is matching, it will be in the completions list.It allows extending matching when there is an exact match already. That is, currently if there is a sub schema that matches exactly what's in the node, and one that could match but has some additional required properties next to it, the one with required properties will not be returned because it has a "problem" which is not having one of the required property.
Also since the best match is initialized with the first of an anyOf regardless of if it has "problems" (due to callFromAutocomplete bypass), the outcomes is highly dependant of the order of the anyOf content. If the first element is a non-restrictive one, it will not have any "problems" and so only the ones without any will match.
When autocompleting I'd expect to have anything matched even if I haven't filled in the required properties yet.
Moreover, it also covers the case where you have, on the opposite, already filled some properties that are required in some
anyOf
elements but not on some others. In such case, if you have a less restrictive element, it should match, however with the previous behaviour it didn't because it had less "matchingPropertiesValues" so the compareTo was not in favor of it.What issues does this PR fix or reference?
fixes #684
some duplicate changes of what's in #1037
Is it tested? How?
Unit tests + some visual testing on a monaco-yaml editor