Use the index in the placeholder expression
Currently the default expression written in the quickpick is (v) => v, I think it should instead be (v, i) => v so that if we actually need to use the index we can do it quicker, and also it hints the user that there's actually a second argument passed to the function.
I agree!!! And perhaps, even adding the backticks and $:
(v, i) => `${v}`
EDIT: It would be nice if the default expression could be defined in "settings.json". So everyone could choose it. For example:
"map-replacejs.default" : "(v, i) => `${v}`"
In the future, it would be nice to be able to define different strings with the posibility to assign them to different keybindings (like macros extension).
For example, a string like:
"map-replacejs.expressions": [
{
"name": "Numerate Markdown",
"text": "(v, i) => `${i}. ${v}.`"
},
{
"name": "Format Strings",
"text": "(v) => v.trim().toUpperCase()"
},
{
"name": "default",
"text": ...
}
]
Thanks for this GREAT extension. Raúl
Thanks @fabiospampinato for bringing up this issue ❤️ The GH notification mail must be lost somethere 😓
Thanks @yaagma for the great suggestion! I just shipped version 0.2.2 with configurable function implementation. Would you mind to open another issue to describe the idea of macro? I would like to close this issue now 👍
Works Ok!!!! And remember to document the new setting in README.md :)
Thank you @Yukaii! Perhaps you might want to rename the setting to map-replacejs.placeholder instead? I think map-replacejs.default isn't very explicative of what it actually does.