Closed aaronmcadam closed 4 years ago
Hi, first of all thanks for a very good bug report. I wish all of them were that descriptive :)
Ok, I see two potential problems here.
One is that app.
is not an expression
but just an identifier
type of context. That's all described here in details.
If that's not self explanatory, let me know, I'll try to rephrase.
Having that in mind you should update the config as follows:
"postfix.customTemplates": [
{
"name": "dl",
"description": "detailed log",
"body": "console.log('{{expr}}', {{expr}});$0",
"when": [
"expression",
"identifier"
]
}
]
expression
will still be handy for object.property.value
or array[index]
code.
The other, less obvious issue is that while trying to repro the problem I have found out that only workspace configuration is taken into account so if this sits in your user settings.json then it won't work. As a workaround just place it into workspace settings.json. I will fix that in next release.
Update: ok, it's slightly different. When postfix.customTemplates
are provided in both user and workspace settings then workspace setting shadows user setting. Settings with the same key are not merged - apparently that's how VSCode works. If you only have it one place everything should be fine. Let me know if that helps.
Thanks so much @ipatalas, it works now by adding support for identifiers. While the docs are good, I think it might be useful to show some example custom templates to help people learn.
Here's my custom template:
See this screen capture: