patch 8.2.0523: loops are repeated
Problem: Loops are repeated.
Solution: Use FOR_ALL_ macros. (Yegappan Lakshmanan, closes #5882)
diff --git a/src/popupmenu.c b/src/popupmenu.c
index c57681c..c6214d2 100644
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -1379,7 +1379,7 @@
int idx = 0;
exarg_T ea;
- for (mp = menu->children; mp != NULL; mp = mp->next)
+ FOR_ALL_CHILD_MENUS(menu, mp)
if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected)
{
vim_memset(&ea, 0, sizeof(ea));
@@ -1407,7 +1407,7 @@
pum_size = 0;
mode = get_menu_mode_flag();
- for (mp = menu->children; mp != NULL; mp = mp->next)
+ FOR_ALL_CHILD_MENUS(menu, mp)
if (menu_is_separator(mp->dname)
|| (mp->modes & mp->enabled & mode))
++pum_size;
@@ -1424,7 +1424,7 @@
if (array == NULL)
return;
- for (mp = menu->children; mp != NULL; mp = mp->next)
+ FOR_ALL_CHILD_MENUS(menu, mp)
if (menu_is_separator(mp->dname))
array[idx++].pum_text = (char_u *)"";
else if (mp->modes & mp->enabled & mode)