yaml-language-server
                                
                                 yaml-language-server copied to clipboard
                                
                                    yaml-language-server copied to clipboard
                            
                            
                            
                        fix: suggest hyphen in array
What does this PR do?
- - (array item)suggestion was missing for some specific situations, for example: enums. it worked ok for 1st item after a colon, but not for 2nd
after fix:
UPDATE
I extended this PR because there were related issues, with a tiny update of this original problem, I can fix another 2 problems:
2) auto add - when hyphen is missing
choose item will produce incorrect yaml
- The default snippet with a simple string will produce this weird result when the string value is defined in snippet body
What issues does this PR fix or reference?
no ref
Is it tested? How?
modified existing added one test for the enum
- check for - array items
- check for -added test for default snippets with string value in thebodyproperty
Hello @msivasubramaniaan, can I ask you for a review?
@gorkem , I don't think that there should be such a filter/condition because schema
{
          type: 'object',
          properties: {
            references: {
              type: 'array',
              items: {
                enum: ['Test', 'Test2'],
              },
            },
}
doesn't define that items of the array have to be unique. To be honest I am not sure how to define this (unique array items)...
This should be allowed based on the schema
items:
 - Test1
 - Test1
 - Test2
or don't you agree? did I understand you incorrectly?
I found another related problem So I converted this PR to a draft I'll try to fix it at once
coverage: 83.841% (+0.03%) from 83.813% when pulling 8e4d05f1bf28c2bb7a6070f4aca3444bb047de0d on jigx-com:fix/suggest-hyphen-in-arrays into ed03cbf71ade29ea62b4bcac0d8952195fd6969d on redhat-developer:main.
Correct, item uniqueness is determined by the schema. The current implementation does not take into account the uniqueItems flag. An improvement to the current implementation would be checking this flag and filtering accordingly. In general, code assist should not suggest values leading to syntax errors, even though it is a trivial fix.