vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

Default value from subschema used for string autocompletion elsewhere

Open wkrill opened this issue 9 months ago • 0 comments

Describe the bug

The default value of a property in one subschema is unintentionally used as default value in string item property.

I have a json schema like so:

{
  "$defs": {
    "Foo": {
      "properties": {
        "foo": {
          "type": "string",
          "default": "hello"
        }
      },
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "foos": {
      "items": {
        "$ref": "#/$defs/Foo"
      },
      "type": "array"
    },
    "bars": {
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "required": [
    "bars",
    "foos"
  ],
  "type": "object"
}

The completions for this schema is shown like this: Image correctly showing the default value for foo but also showing ${1} for bar. When hitting enter, the default value is applied to the bar element as well: Image

Expected Behavior

I expect the default value to only show up for the property it is defined for.

Current Behavior

Default value shows up unexpectedly in wrong place.

Steps to Reproduce

  1. Copy the schema
  2. ctrl + space in new file which uses the schema
  3. hit enter

Environment

  • [ ] Windows
  • [ ] Mac
  • [x] Linux
  • [ ] other (please specify)

wkrill avatar Dec 27 '24 14:12 wkrill