From 049de6f11925131364d2820ed53327b1c32af012 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Aug 2025 08:32:46 +0800 Subject: vim-patch:partial:308a313: runtime(doc): Update help for the items() function closes: vim/vim#18021 https://github.com/vim/vim/commit/308a3130be89148cdaf83bfaf00e3e7c69ed2133 Co-authored-by: Yegappan Lakshmanan --- runtime/lua/vim/_meta/vimfn.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index c1ac7c3fab..5312167c44 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -4908,22 +4908,26 @@ function vim.fn.islocked(expr) end --- @return 0|1 function vim.fn.isnan(expr) end ---- Return a |List| with all the key-value pairs of {dict}. Each ---- |List| item is a list with two items: the key of a {dict} ---- entry and the value of this entry. The |List| is in arbitrary ---- order. Also see |keys()| and |values()|. +--- Return a |List| with all the key/index and value pairs of {expr}. +--- Each |List| item is a list with two items: +--- - for a |Dict|: the key and the value +--- - for a |List| or |String|: the index and the value +--- The |List| is in arbitrary order. +--- +--- Also see |keys()| and |values()|. +--- --- Example: >vim +--- let mydict = #{a: 'red', b: 'blue'} --- for [key, value] in items(mydict) ---- echo key .. ': ' .. value +--- echo $"{key} = {value}" --- endfor +--- echo items([1, 2, 3]) +--- echo items("foobar") --- < ---- A List or a String argument is also supported. In these ---- cases, items() returns a List with the index and the value at ---- the index. --- ---- @param dict table +--- @param expr table|string --- @return any -function vim.fn.items(dict) end +function vim.fn.items(expr) end --- @deprecated --- Obsolete name for |chanclose()| -- cgit From 1fdacbb3e4e118c7bc3cd03ea16b21a68c7c9631 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Aug 2025 08:34:20 +0800 Subject: vim-patch:44c8072: runtime(doc): fix style and clarify items() function for String type related: vim/vim#18021 https://github.com/vim/vim/commit/44c8072ef64a7a218eb8cf4b72866921762633e4 Co-authored-by: Christian Brabandt --- runtime/lua/vim/_meta/vimfn.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 5312167c44..3d96bf7255 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -4908,7 +4908,7 @@ function vim.fn.islocked(expr) end --- @return 0|1 function vim.fn.isnan(expr) end ---- Return a |List| with all the key/index and value pairs of {expr}. +--- Return a |List| with all key/index and value pairs of {expr}. --- Each |List| item is a list with two items: --- - for a |Dict|: the key and the value --- - for a |List| or |String|: the index and the value -- cgit From 7d53982b7f7991e27ebffd5159de012d900a244c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Aug 2025 08:35:30 +0800 Subject: vim-patch:84a343a: runtime(doc): correct another problem in :h items() The returned value is only in arbitrary order for a Dict. closes: vim/vim#18050 https://github.com/vim/vim/commit/84a343a6ed34995adc67c062b64533c1b0bf7fb1 --- runtime/lua/vim/_meta/vimfn.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 3d96bf7255..af8e4b786c 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -4912,7 +4912,8 @@ function vim.fn.isnan(expr) end --- Each |List| item is a list with two items: --- - for a |Dict|: the key and the value --- - for a |List| or |String|: the index and the value ---- The |List| is in arbitrary order. +--- The returned |List| is in arbitrary order for a |Dict|, +--- otherwise it's in ascending order of the index. --- --- Also see |keys()| and |values()|. --- -- cgit