Skip to content

Conversation

rickcowan
Copy link
Contributor

What does this PR do?

Fixes an issue where default snippets where not being entered correctly within an array.

Given the following schema:

{
  "type": "object",
  "properties": {
    "array1": {
      "type": "array",
      "items": {
        "type": "object",
        "defaultSnippets": [
          {
            "label": "My array item",
            "body": { "item1": "$1" }
          }
        ],
        "required": ["thing1"],
        "properties": {
          "thing1": {
            "type": "object",
            "required": ["item1"],
            "properties": {
              "item1": { "type": "string" }
            }
          }
        }
      }
    }
  }
}

When autocomplete is attempted on:

array1:
  - thing1:
      item1: aa
  #cursor here

It previously autocompleted to:

array1:
  - thing1:
      item1: aa

      item1:

After the fix it correctly indents as:

array1:
  - thing1:
      item1: aa
  - item1: 

What issues does this PR fix or reference?

no ref

Is it tested? How?

Manual testing and unit test.

@coveralls
Copy link

coveralls commented Jul 27, 2022

Coverage Status

Coverage decreased (-0.01%) to 83.187% when pulling 3c0e7b5 on jigx-com:fix/main-default-snippet-in-array into e200432 on redhat-developer:main.

gorkem
gorkem previously approved these changes Aug 2, 2022
Copy link
Collaborator

@gorkem gorkem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the contribution

Copy link
Contributor

@msivasubramaniaan msivasubramaniaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve the conflicts

@p-spacek
Copy link
Contributor

Please resolve the conflicts

Hello, I merged the code and resolved conflicts, there were some problems with the test.
I would suggest reviewing it again?.

I left a little bit related comment here in this PR https://github.com/redhat-developer/yaml-language-server/pull/786/files#r1029764436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants