For now, we can only use when to narrow down locations, in which postfixes are suggested. However there are variable name conventions (such as Idx or Index). Just a few examples:
Code Examples
const dotIdx = 0
dotIdx.notFound
// =>
if (dotIdx === -1) return
Template Examples
{
"name": "notFound",
"body": "if ({{expr}} === -1) ${1:return}",
"exprLastRegex": "(Idx|Index)$",
"when": [
"identifier",
"expression"
]
},
Of course, I could use just exprRegex here, but exprLastRegex can be useful for method calls.
It is really cool, as we can use different postfixes with the same name for different variable name patterns.
Why regexs? Because there are easy to construct. Also as I know regex engine in JS is pretty fast.
For now, we can only use
whento narrow down locations, in which postfixes are suggested. However there are variable name conventions (such asIdxorIndex). Just a few examples:Code Examples
Template Examples
{ "name": "notFound", "body": "if ({{expr}} === -1) ${1:return}", "exprLastRegex": "(Idx|Index)$", "when": [ "identifier", "expression" ] },Of course, I could use just
exprRegexhere, butexprLastRegexcan be useful for method calls.It is really cool, as we can use different postfixes with the same name for different variable name patterns.
Why regexs? Because there are easy to construct. Also as I know regex engine in JS is pretty fast.