Hi,
On Sun, Sep 13, 2020 at 2:44 PM Prabir Shrestha <[email protected]>
wrote:
> Would it be possible to take a dict but instead of using key or callback
> name it map or something else but make the inner implementation smarter?
>
> let result = matchfuzzy(items, 'search', { 'map': 'v:val["word"]' })
>
> If map is string you can try extracting the key by using regex. Since
> this regex will happen only once cost wouldn't be that high.
>
It is better to explicitly supply the name of the key to the function.
Using a
regular expression to guess and automatically extract the key name will
lead to
errors.
- Yegappan
>From here https://regex101.com/
>
> Regular Expression: ^v:val\[(\'|\")(.*)(\'|\")\]$
>
> Test String:
>
> v:val['key']
> v:val["key"]
>
> Notice how group two contains the key.
>
> [image: Screen Shot 2020-09-13 at 2 40 34 PM]
> <https://user-images.githubusercontent.com/287744/93029343-3c7bc080-f5cf-11ea-9dda-624d1b2b6d09.png>
>
> If map is of not of type script it can be a callback.
>
> One could do this.
>
> let result = matchfuzzy(items, 'search', { 'map': {item->item['word'] })
>
>
>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/CAAW7x7n717mPwNS7tBJj047SDAw_hk859oAAvv9gSjViEi8-mQ%40mail.gmail.com.