patch 8.2.3459: Vim9: need more tests for empty string arguments
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)
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 977473a..00ba2e4 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -7938,7 +7938,8 @@
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 @@
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')