Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object autocompletion in arrays with custom indentation produces invalid output #432

Closed
1 of 4 tasks
TedDriggs opened this issue Feb 17, 2021 · 2 comments
Closed
1 of 4 tasks
Assignees
Labels
Milestone

Comments

@TedDriggs
Copy link

Describe the bug

I have a YAML file with a schema defined in .vscode/settings.json, along with a custom YAML setting of editor.tabSize: 4. When I use the array autocompletion, the following happens:

Array Completion Indentation

I believe that the generated keys have gone one indentation deeper than their parent, without realizing that an array parent only goes in two spaces.

Expected Behavior

The model, weight, and criteria keys should be aligned with id.

Current Behavior

See screenshot

Steps to Reproduce

  1. Set .vscode/settings.json with a YAML override, as described above
  2. Create a schema with an array of objects
  3. Attempt to add an item to the list

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
@evidolob
Copy link
Collaborator

@TedDriggs Can you share JSON Schema that you used? I cannot reproduce this with my schemas.

@TedDriggs
Copy link
Author

TedDriggs commented Feb 22, 2021

Here's the one for the file where the error was taking place

{
    "additionalProperties": {
        "properties": {
            "field": {
                "type": "string"
            },
            "variants": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/variant",
                    "uniqueItems": true
                }
            },
            "default": {
                "$ref": "#/definitions/variant"
            },
            "inputs": {
                "type": "object",
                "additionalProperties": {
                    "type": "object",
                    "additionalProperties": {
                        "$ref": "#/definitions/variant"
                    }
                }
            },
            "rules": {
                "type": "array",
                "items": {
                    "$ref": "./rules.schema.json#/definitions/rule"
                }
            }
        },
        "required": ["field", "variants", "inputs", "rules"]
    },
    "definitions": {
        "variant": {
            "type": "string",
            "pattern": "[a-z][a-z\\d_]*"
        }
    }
}

And here's the referenced rules.schema.json.

{
    "type": "array",
    "items": {
        "$ref": "#/definitions/rule"
    },
    "definitions": {
        "rule": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "notes": {
                    "type": "string"
                },
                "links": {
                    "type": "array",
                    "items": {
                        "properties": {
                            "rel": {
                                "type": "string"
                            },
                            "url": {
                                "type": "string"
                            }
                        }
                    }
                },
                "nomination": {
                    "type": "string",
                    "pattern": "[a-z0-9_]+"
                },
                "weight": {
                    "type": "number",
                    "minimum": 1
                },
                "criteria": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "type": "object",
                        "properties": {
                            "field": {
                                "type": "string"
                            },
                            "operator": {
                                "type": "string"
                            },
                            "operand": {
                                "type": "string"
                            }
                        },
                        "required": ["field", "operator", "operand"],
                        "additionalProperties": false
                    }
                }
            },
            "required": ["id", "weight", "criteria", "nomination"]
        }
    }
}

And then here's the .vscode/settings.json file I'm using:

{
    "yaml.schemas": {
        "./schemas/runoffs.schema.json": ["*.runoffs.yaml"]
    },
    "[yaml]": {
        "editor.tabSize": 4
    }
}

@evidolob evidolob added this to the 0.16.0 milestone Feb 23, 2021
bleach31 pushed a commit to bleach31/vscode-yaml that referenced this issue Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants