Closed zardoy closed 2 years ago
Oh, this might be tricky as the idea was to only analyze what's before the triggering postfix template. That means it was always meant to be used at the end of the expression so it might be tricky but I'll have a look.
Btw can you give me more meaningful example of why would you like to auto-complete in the middle? I don't get this example above.
Yes! I remembered two snippets, where this behavior was really annoying. Consider these extremely useful snippets:
{
"name": "moreArr",
"description": "",
"body": "[...{{expr}}, $1]",
"when": ["identifier", "expression", "function-call"]
},
{
"name": "moreObj",
"description": "",
"body": "{...{{expr}}, $1}",
"when": ["identifier", "expression", "function-call"]
},
Example code:
const someStrings = ['I', 'love']
console.log(someStrings/*.moreArr*/.reduce((prev, str) => `${prev} ${str}`, ''))
// actual (see issue body for different cases)
console.log([...someStrings., ].reduce((prev, str) => `${prev} ${str}`, ''))
// expected
console.log([...someStrings, 'postfixes'].reduce((prev, str) => `${prev} ${str}`, ''))
// another example
Of course, I could wrap this expression into brackets and write ...
but I would lose a lot of time on this (that's why I use this extension!).
Cool, that makes sense, I'll have a look.
Published a fix
Hey! I have the following snippet:
And I usually like to use it in the middle of expression to fix TS errors like this:
However:
Writing
a.a
and then adding.entries
after firsta
without retriggering completions insertsObject.entries(a.).a
(would be ideal if it didn't place that trailing.
)Writing
a.ent.a.
(ora.entries.a
) and only then triggering completions inserts postfix itself e.g.Object.entries(a.ent)a
.