forked from aniani/vim
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)
This commit is contained in:
committed by
Bram Moolenaar
parent
be01090efa
commit
51491adfa8
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user