diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-09-30 19:00:00 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-09-30 19:00:00 +0100 |
commit | 51491adfa86fd66a857cd7ec50d0b57dbdf3da59 (patch) | |
tree | 0eeb61a9d9c7e2e178e6649ae5961232728cf987 /src/menu.c | |
parent | be01090efad242e30728275dea05420db6f96257 (diff) |
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 'src/menu.c')
-rw-r--r-- | src/menu.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/menu.c b/src/menu.c index b9f7db2c0d..2cd3270fe4 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2830,9 +2830,27 @@ menu_translate_tab_and_shift(char_u *arg_start) * Get the information about a menu item in mode 'which' */ static int -menuitem_getinfo(vimmenu_T *menu, int modes, dict_T *dict) +menuitem_getinfo(char_u *menu_name, vimmenu_T *menu, int modes, dict_T *dict) { int status; + list_T *l; + + if (*menu_name == NUL) + { + // Return all the top-level menus + vimmenu_T *topmenu; + + l = list_alloc(); + if (l == NULL) + return FAIL; + + dict_add_list(dict, "submenus", l); + // get all the children. Skip PopUp[nvoci]. + for (topmenu = menu; topmenu != NULL; topmenu = topmenu->next) + if (!menu_is_hidden(topmenu->dname)) + list_append_string(l, topmenu->dname, -1); + return OK; + } if (menu_is_tearoff(menu->dname)) // skip tearoff menu item return OK; @@ -2903,9 +2921,9 @@ menuitem_getinfo(vimmenu_T *menu, int modes, dict_T *dict) // If there are submenus, add all the submenu display names if (status == OK && menu->children != NULL) { - list_T *l = list_alloc(); vimmenu_T *child; + l = list_alloc(); if (l == NULL) return FAIL; @@ -2992,7 +3010,7 @@ f_menu_info(typval_T *argvars, typval_T *rettv) return; if (menu->modes & modes) - menuitem_getinfo(menu, modes, retdict); + menuitem_getinfo(menu_name, menu, modes, retdict); } #endif // FEAT_MENU |