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

default value dollar sign is not completely escaped

Open rH4rtinger opened this issue 2 years ago • 0 comments

Describe the bug

I think this is a follow up from https://github.com/redhat-developer/vscode-yaml/issues/258.

I have a schema with an default value that starts with an dollar sign. These values are in the root properties and in children properties.

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "type": "string",
                    "default": "$TEMP"
                }
            },
            "required": ["bar"]
        },
        "baz": {
            "type": "string",
            "default": "$TEMP"
        }
    },
    "required": ["foo", "baz"]
}

When I now add this schema to an file and try to create this file via CTRL+Space and Tab, I get the following preview and YAML.

image

foo:
  bar: 
baz: $TEMP

As you see from the yaml and the image, the $TEMP of baz gets escaped and will be correctly displayed in the yaml. However, my bar value will not be displayed correctly. It looks like the $ sign is not correctly escaped.

As a workaround, I could write "default": "\\$TEMP" in my schema, however this is not the perfect way, because baz is working correctly.

Expected Behavior

I expect that all my $ signs in the json schema will be escaped and not only the ones from the first properties.

Current Behavior

Currently only the first layer of properties will have escaped dollar signs, nested properties will not be escaped

Steps to Reproduce

  1. add the schema from above to VSCode
  2. Create a new file and use the above schema
  3. press CTRL+Space and tab to see the generated result

Environment

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

rH4rtinger avatar Jul 17 '23 11:07 rH4rtinger