redhat-developer / redhat-developer/vscode-yaml

IntelliSence shows just enum subschema value when there is the same named property as the single enum value

Open
#1,024 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

IntelliSence shows just one of two oneOf branches when both should be shown. oneOf branches:

  • a branch with a single-valued enum with some value (referred later as {{value}})
  • a branch with an object with a property named as {{value}}

image

Note: the same applies for anyOf too.

Expected Behavior

Both branches suggested in IntelliSence.

Current Behavior

A branch with a single-valued enum suggested.

Steps to Reproduce

  1. Create schema schema.json with this content:
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "array",
    "items": {
        "oneOf": [
            {
                "$comment": "A branch with a single-valued enum which is shown in IntelliSense suggestions",
                "type": "string",
                "enum": [
                    "something"
                ]
            },
            {
                "$comment": "A branch with a single-valued enum which is hidden from IntelliSense suggestions",
                "type": "object",
                "properties": {
                    "something": {
                        "$comment": "Note that enum value 'something' named the same as this property, which is the source of an issue",
                        "title": "something",
                        "default": "default"
                    }
                },
                "additionalProperties": false
            }
        ]
    }
}
  1. Create test.yaml file and refer inside it to schema.json:
# yaml-language-server: $schema=schema.json

- # cursor is right before the hash sign
  1. Press Ctrl+Space and get just one oneOf branch suggested.

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

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 completion behavior using the schema.json and test.yaml examples, then trace the IntelliSense handling for oneOf and anyOf branches. Done means Ctrl+Space suggests both the single-valued enum branch and the object branch when the enum value matches the property name.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.