redhat-developer / redhat-developer/vscode-yaml
Suggest "defaultSnippets" for object and array typed properties when completion is done
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
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
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