Open zardoy opened 2 years ago
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:
when
Idx
Index
const dotIdx = 0 dotIdx.notFound // => if (dotIdx === -1) return
{ "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.
exprRegex
exprLastRegex
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.
Of course it is also easy to implement, but I'll wait until https://github.com/ipatalas/vscode-postfix-ts/pull/91 is resolved ;)
For now, we can only use
when
to narrow down locations, in which postfixes are suggested. However there are variable name conventions (such asIdx
orIndex
). Just a few examples:Code Examples
Template Examples
Of course, I could use just
exprRegex
here, butexprLastRegex
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.