map-replace.js icon indicating copy to clipboard operation
map-replace.js copied to clipboard

Use the index in the placeholder expression

Open fabiospampinato opened this issue 6 years ago • 4 comments

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.

fabiospampinato avatar Apr 18 '19 13:04 fabiospampinato

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

yaagma avatar Apr 25 '19 10:04 yaagma

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 👍

Yukaii avatar Apr 25 '19 16:04 Yukaii

Works Ok!!!! And remember to document the new setting in README.md :)

yaagma avatar Apr 25 '19 17:04 yaagma

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.

fabiospampinato avatar Apr 25 '19 17:04 fabiospampinato