Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fbaligand opened this issue Jan 3, 2025 · 0 comments

Comments

@fbaligand
Copy link
Contributor

fbaligand commented Jan 3, 2025

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.

@fbaligand fbaligand changed the title Purpose "defaultSnippets" when completion is done Suggest "defaultSnippets" when completion is done Jan 3, 2025
@fbaligand fbaligand changed the title Suggest "defaultSnippets" when completion is done Suggest "defaultSnippets" for object and array typed properties when completion is done Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant