redhat-developer / redhat-developer/vscode-yaml

Suggest "defaultSnippets" for object and array typed properties when completion is done

Open
#1,077 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

Is your enhancement related to a problem? Please describe.

When I use completion for a property (say "myProperty"), the automatically generated snippet is only myProperty: .
Up to me, I'm frustrated because I would like that IDE suggests to me, by default, the list of "defaultSnippets", and if there is only one "defaultSnippet", then the one is automatically played (without showing the list).
Currently, I have to manually tape "tab" to have the list of snippets, which is a pity.
By the way, this is precisely the behavior in VSCODE itself for JSON files associated to a JSON schema.
So this would be great to have the same completion behavior than VSCODE for JSON files.

Describe the solution you would like
  • When a property has a single defaultSnippet, play directly the single snippet when completion is done
  • When a property has several defaultSnippets, show directly the list of snippets
Example

Given this json schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "defaultSnippets": [
                {
                    "label": "(snippet)",
                    "body": "${1|John,Doe|}"
                }
            ]
        },
        "myProperty": {
            "type": "object",
            "defaultSnippets": [
                {
                    "label": "myProperty",
                    "body": {
                        "name": "John"
                    }
                }
            ],
            "properties": {
                "name": {
                    "type": "string",
                    "defaultSnippets": [
                        {
                            "label": "Name",
                            "body": "${1:John}"
                        }
                    ]
                }
            }
        }
    }
}

If I play completion for "name" property, then I get automatically the default snippet played.
If I play completion for "myProperty" property, then I don't get automatically the default snippet played.

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

No file or test is named in the issue; begin by locating the TypeScript completion entry point for JSON-schema properties and the handling of object and array defaultSnippets, then compare its behavior with VS Code's JSON completion. Done means a single default snippet is inserted on completion and multiple snippets open the choices directly, with coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.