Mercurial > vim
comparison src/menu.c @ 25850:6f615b2fdc66 v8.2.3459
patch 8.2.3459: Vim9: need more tests for empty string arguments
Commit: https://github.com/vim/vim/commit/51491adfa86fd66a857cd7ec50d0b57dbdf3da59
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Sep 30 19:00:00 2021 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 30 Sep 2021 20:15:04 +0200 |
parents | e8e2c4d33b9b |
children | fc859aea8cec |
comparison
equal
deleted
inserted
replaced
25849:ecbd01ddf78d | 25850:6f615b2fdc66 |
---|---|
2828 | 2828 |
2829 /* | 2829 /* |
2830 * Get the information about a menu item in mode 'which' | 2830 * Get the information about a menu item in mode 'which' |
2831 */ | 2831 */ |
2832 static int | 2832 static int |
2833 menuitem_getinfo(vimmenu_T *menu, int modes, dict_T *dict) | 2833 menuitem_getinfo(char_u *menu_name, vimmenu_T *menu, int modes, dict_T *dict) |
2834 { | 2834 { |
2835 int status; | 2835 int status; |
2836 list_T *l; | |
2837 | |
2838 if (*menu_name == NUL) | |
2839 { | |
2840 // Return all the top-level menus | |
2841 vimmenu_T *topmenu; | |
2842 | |
2843 l = list_alloc(); | |
2844 if (l == NULL) | |
2845 return FAIL; | |
2846 | |
2847 dict_add_list(dict, "submenus", l); | |
2848 // get all the children. Skip PopUp[nvoci]. | |
2849 for (topmenu = menu; topmenu != NULL; topmenu = topmenu->next) | |
2850 if (!menu_is_hidden(topmenu->dname)) | |
2851 list_append_string(l, topmenu->dname, -1); | |
2852 return OK; | |
2853 } | |
2836 | 2854 |
2837 if (menu_is_tearoff(menu->dname)) // skip tearoff menu item | 2855 if (menu_is_tearoff(menu->dname)) // skip tearoff menu item |
2838 return OK; | 2856 return OK; |
2839 | 2857 |
2840 status = dict_add_string(dict, "name", menu->name); | 2858 status = dict_add_string(dict, "name", menu->name); |
2901 } | 2919 } |
2902 | 2920 |
2903 // If there are submenus, add all the submenu display names | 2921 // If there are submenus, add all the submenu display names |
2904 if (status == OK && menu->children != NULL) | 2922 if (status == OK && menu->children != NULL) |
2905 { | 2923 { |
2906 list_T *l = list_alloc(); | |
2907 vimmenu_T *child; | 2924 vimmenu_T *child; |
2908 | 2925 |
2926 l = list_alloc(); | |
2909 if (l == NULL) | 2927 if (l == NULL) |
2910 return FAIL; | 2928 return FAIL; |
2911 | 2929 |
2912 dict_add_list(dict, "submenus", l); | 2930 dict_add_list(dict, "submenus", l); |
2913 child = menu->children; | 2931 child = menu->children; |
2990 | 3008 |
2991 if (menu == NULL) // specified menu not found | 3009 if (menu == NULL) // specified menu not found |
2992 return; | 3010 return; |
2993 | 3011 |
2994 if (menu->modes & modes) | 3012 if (menu->modes & modes) |
2995 menuitem_getinfo(menu, modes, retdict); | 3013 menuitem_getinfo(menu_name, menu, modes, retdict); |
2996 } | 3014 } |
2997 | 3015 |
2998 #endif // FEAT_MENU | 3016 #endif // FEAT_MENU |