From 8cbb2477cf70ea29105e3df17308e6d6a067c8e6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Aug 2023 09:43:00 +0800 Subject: vim-patch:8.2.1969: Vim9: map() may change the list or dict item type Problem: Vim9: map() may change the list or dict item type. Solution: Add mapnew(). https://github.com/vim/vim/commit/ea696852e7abcdebaf7f17a7f23dc90df1f5e2ed Co-authored-by: Bram Moolenaar --- runtime/lua/vim/_meta/vimfn.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'runtime/lua') diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index d1173e8a42..3782f4bf2f 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -4922,6 +4922,8 @@ function vim.fn.log10(expr) end --- {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|. --- @@ -5078,6 +5080,15 @@ function vim.fn.maparg(name, mode, abbr, dict) end --- @return any function vim.fn.mapcheck(name, mode, abbr) end +--- Like |map()| but instead of replacing items in {expr1} a new +--- List or Dictionary is created and returned. {expr1} remains +--- unchanged. +--- +--- @param expr1 any +--- @param expr2 any +--- @return any +function vim.fn.mapnew(expr1, expr2) end + --- Restore a mapping from a dictionary returned by |maparg()|. --- {mode} and {abbr} should be the same as for the call to --- |maparg()|. *E460* -- cgit From 3117dc70f1e60569f5c3cc0eee5f5005081722b5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Aug 2023 11:08:21 +0800 Subject: vim-patch:1b884a005398 Update runtime files. https://github.com/vim/vim/commit/1b884a0053982335f644eec6c71027706bf3c522 Co-authored-by: Bram Moolenaar --- runtime/lua/vim/_meta/vimfn.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/lua') diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 3782f4bf2f..b48e2beb8d 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -5082,7 +5082,8 @@ function vim.fn.mapcheck(name, mode, abbr) end --- Like |map()| but instead of replacing items in {expr1} a new --- List or Dictionary is created and returned. {expr1} remains ---- unchanged. +--- unchanged. Items can still be changed by {expr2}, if you +--- don't want that use |deepcopy()| first. --- --- @param expr1 any --- @param expr2 any -- cgit