aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-17 11:47:40 +0800
committerGitHub <noreply@github.com>2023-08-17 11:47:40 +0800
commit8861f2af72481b1759a6935afa6dce2aae512359 (patch)
tree292843cc0ce14205b328fec6b75c1ad9a0ad7c9b /src/nvim/eval.lua
parent22d9338afceae5f8ef3845f152dea07a19d512d1 (diff)
parent3117dc70f1e60569f5c3cc0eee5f5005081722b5 (diff)
downloadrneovim-8861f2af72481b1759a6935afa6dce2aae512359.tar.gz
rneovim-8861f2af72481b1759a6935afa6dce2aae512359.tar.bz2
rneovim-8861f2af72481b1759a6935afa6dce2aae512359.zip
Merge pull request #24747 from zeertzjq/vim-8.2.1969
vim-patch:8.2.{1969,1971,2075}: mapnew()
Diffstat (limited to 'src/nvim/eval.lua')
-rw-r--r--src/nvim/eval.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 8a36509f9a..97b10a46c0 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -6053,6 +6053,8 @@ M.funcs = {
{expr1} must be a |List|, |Blob| or |Dictionary|.
Replace each item in {expr1} with the result of evaluating
{expr2}. For a |Blob| each byte is replaced.
+ If the item type changes you may want to use |mapnew()| to
+ create a new List or Dictionary.
{expr2} must be a |string| or |Funcref|.
@@ -6215,6 +6217,19 @@ M.funcs = {
params = { { 'name', 'string' }, { 'mode', 'string' }, { 'abbr', 'any' } },
signature = 'mapcheck({name} [, {mode} [, {abbr}]])',
},
+ mapnew = {
+ args = 2,
+ base = 1,
+ desc = [=[
+ Like |map()| but instead of replacing items in {expr1} a new
+ List or Dictionary is created and returned. {expr1} remains
+ unchanged. Items can still be changed by {expr2}, if you
+ don't want that use |deepcopy()| first.
+ ]=],
+ name = 'mapnew',
+ params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
+ signature = 'mapnew({expr1}, {expr2})',
+ },
mapset = {
args = 3,
base = 1,