summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-09-30 19:00:00 +0100
committerBram Moolenaar <Bram@vim.org>2021-09-30 19:00:00 +0100
commit51491adfa86fd66a857cd7ec50d0b57dbdf3da59 (patch)
tree0eeb61a9d9c7e2e178e6649ae5961232728cf987 /runtime
parentbe01090efad242e30728275dea05420db6f96257 (diff)
downloadvim-git-51491adfa86fd66a857cd7ec50d0b57dbdf3da59.tar.gz
patch 8.2.3459: Vim9: need more tests for empty string argumentsv8.2.3459
Problem: Vim9: need more tests for empty string arguments. Solution: Add more tests. Also use empty argument with menu_info() to get the top-level menu names. (Yegappan Lakshmanan, closes #8925)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt17
1 files changed, 16 insertions, 1 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 977473a2e..00ba2e41b 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -7938,7 +7938,8 @@ max({expr}) Return the maximum value of all items in {expr}. Example: >
menu_info({name} [, {mode}]) *menu_info()*
Return information about the specified menu {name} in
mode {mode}. The menu name should be specified without the
- shortcut character ('&').
+ shortcut character ('&'). If {name} is "", then the top-level
+ menu names are returned.
{mode} can be one of these strings:
"n" Normal
@@ -7989,6 +7990,20 @@ menu_info({name} [, {mode}]) *menu_info()*
Examples: >
:echo menu_info('Edit.Cut')
:echo menu_info('File.Save', 'n')
+
+ " Display the entire menu hierarchy in a buffer
+ func ShowMenu(name, pfx)
+ let m = menu_info(a:name)
+ call append(line('$'), a:pfx .. m.display)
+ for child in m->get('submenus', [])
+ call ShowMenu(a:name .. '.' .. escape(child, '.'),
+ \ a:pfx .. ' ')
+ endfor
+ endfunc
+ new
+ for topmenu in menu_info('').submenus
+ call ShowMenu(topmenu, '')
+ endfor
<
Can also be used as a |method|: >
GetMenuName()->menu_info('v')