aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-17 11:08:21 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-08-17 11:21:10 +0800
commit3117dc70f1e60569f5c3cc0eee5f5005081722b5 (patch)
tree292843cc0ce14205b328fec6b75c1ad9a0ad7c9b
parent90ad3c8f17d4d0be4149ea28c49d1e6980640d38 (diff)
downloadrneovim-3117dc70f1e60569f5c3cc0eee5f5005081722b5.tar.gz
rneovim-3117dc70f1e60569f5c3cc0eee5f5005081722b5.tar.bz2
rneovim-3117dc70f1e60569f5c3cc0eee5f5005081722b5.zip
vim-patch:1b884a005398
Update runtime files. https://github.com/vim/vim/commit/1b884a0053982335f644eec6c71027706bf3c522 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--runtime/doc/builtin.txt3
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua3
-rw-r--r--src/nvim/eval.lua3
-rw-r--r--test/old/testdir/vim9.vim4
4 files changed, 8 insertions, 5 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 04c4ce60c3..a51f14aab0 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -4210,7 +4210,8 @@ mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
mapnew({expr1}, {expr2}) *mapnew()*
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.
mapset({mode}, {abbr}, {dict}) *mapset()*
Restore a mapping from a dictionary returned by |maparg()|.
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
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 8bfea4938b..97b10a46c0 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -6223,7 +6223,8 @@ M.funcs = {
desc = [=[
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.
]=],
name = 'mapnew',
params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim
index 1b436d7b3c..825f01c9d6 100644
--- a/test/old/testdir/vim9.vim
+++ b/test/old/testdir/vim9.vim
@@ -88,7 +88,7 @@ endfunc
" Execute "lines" in a legacy function, translated as in
" CheckLegacyAndVim9Success()
func CheckTransLegacySuccess(lines)
- let legacylines = a:lines->deepcopy()->map({_, v ->
+ let legacylines = a:lines->mapnew({_, v ->
\ v->substitute('\<VAR\>', 'let', 'g')
\ ->substitute('\<LET\>', 'let', 'g')
\ ->substitute('\<LSTART\>', '{', 'g')
@@ -131,7 +131,7 @@ func CheckLegacyAndVim9Failure(lines, error)
let legacyError = a:error[0]
endif
- let legacylines = a:lines->deepcopy()->map({_, v ->
+ let legacylines = a:lines->mapnew({_, v ->
\ v->substitute('\<VAR\>', 'let', 'g')
\ ->substitute('\<LET\>', 'let', 'g')
\ ->substitute('#"', ' "', 'g')