redhat-developer / redhat-developer/vscode-yaml

Wrong indents number when trying to generate the whole suggested object

Open
#715 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
830
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

Describe the bug

Due to experiments with the JSON schema and the YAML extension I find a little bug when I've tried to generate the suggested object.

The problem is with the fields field with is an array that has two objects with three fields each.

Generating the whole subscription object causes adding one element to the array but all three fields are on the same indent level that they parent.

I've tried exactly the same configuration with other IDEs and everything works fine.

Expected Behavior

Generated object should looks like:
Screenshot 2022-03-13 at 19 00 00

Current Behavior

Generated object:
Screenshot 2022-03-13 at 18 58 38

Steps to Reproduce

  1. to the .vscode folder add the following files:
{
  "$schema": "http://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/kyma-incubator/hydroform/function/pkg/workspace/cfg",
  "$ref": "#/$defs/Cfg",
  "$defs": {
    "Cfg": {
      "properties": {
        "subscriptions": {
          "items": {
            "$ref": "#/$defs/Subscription"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "EventFilter": {
      "properties": {
        "eventSource": {
          "$ref": "#/$defs/EventSource"
        },
        "eventType": {
          "$ref": "#/$defs/EventType"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "eventSource",
        "eventType"
      ]
    },
    "EventSource": {
      "properties": {
        "property": {
          "type": "string",
          "default": "source"
        },
        "type": {
          "type": "string",
          "default": "exact"
        },
        "value": {
          "type": "string",
          "default": "\"\""
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "property",
        "type",
        "value"
      ]
    },
    "EventType": {
      "properties": {
        "property": {
          "type": "string",
          "default": "type"
        },
        "type": {
          "type": "string",
          "default": "exact"
        },
        "value": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "property",
        "type",
        "value"
      ]
    },
    "Filter": {
      "properties": {
        "dialect": {
          "type": "string"
        },
        "filters": {
          "items": {
            "$ref": "#/$defs/EventFilter"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "filters"
      ]
    },
    "Subscription": {
      "properties": {
        "name": {
          "type": "string"
        },
        "protocol": {
          "type": "string",
          "default": "\"\""
        },
        "filter": {
          "$ref": "#/$defs/Filter"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "protocol",
        "filter"
      ]
    }
  }
}

settings.json

{
  "yaml.schemas": {
    ".vscode/schema.json": "/config.yaml"
  }
}
  1. In the main project create file config.yaml.
  2. In the config.yaml generate suggested object:
Screenshot 2022-03-13 at 19 00 11 5. Press enter

Environment

YAML extension: v1.5.1

Version: 1.65.2
Commit: c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1
Date: 2022-03-10T14:33:49.188Z (3 days ago)
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 21.3.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using .vscode/schema.json, settings.json, and config.yaml with the provided schema and YAML extension versions. Start by tracing schema-based completion generation for the nested subscriptions array and compare its indentation with the expected screenshot. Done means generating the whole subscription object preserves the nested fields' indentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
json, typescript, yaml
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.