redhat-developer / redhat-developer/vscode-yaml
Invalid auto-complete when `const` is an object
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Describe the bug
When the value of const is an object, the auto-complete for the property/instance is garbled and invalid.
Instead of:
foo:
bar: baz
It auto-completes as:
foo:
bar}: ${2:baz
Expected Behavior
Auto-complete for constant values should insert correctly, even when the constant is an object, as it does when the constant is an array, string, number, or null.
Current Behavior
Auto-complete inserts what appears to be a broken internal string.
Steps to Reproduce
-
Define a test schema as
test.schema.json:{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Schema with an object constant", "description": "Defines a schema with an object constant.", "type": "object", "properties": { "foo": { "title": "Property with an object constant", "const": { "bar": "baz" } } } } -
Define a test instance using that schema as
test.instance.yaml:# yaml-language-server: $schema=test.schema.json -
Type
foo, wait for IntelliSense, then press enter. -
Result:
# yaml-language-server: $schema=test.schema.yaml foo: bar}: ${2:baz -
Define a test instance as
test.schema.json{ "$schema": "test.schema.json" } -
Add a comma, then use IntelliSense to find the
fooproperty and press enter to auto-complete. -
Result:
{ "$schema": "test.schema.json", "foo": { "bar": "baz" } }
Environment
- Windows
- Mac
- Linux
- other (please specify)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with test.schema.json and test.instance.yaml, using IntelliSense on the foo property with an object const. Trace the autocomplete handling for object constants and compare it with the documented array, string, number, and null cases. Done means both YAML and JSON insert valid object values without malformed snippet placeholders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100