Skip to content

Commit d558443

Browse files
authored
Merge pull request #603 from dougfales/fix-popup-menu-items
In ex_macmenu, add the mac action to each of the PopUp mode menus
2 parents 594349b + 5ebd0d1 commit d558443

1 file changed

Lines changed: 41 additions & 9 deletions

File tree

src/menu.c

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,27 @@ menu_for_path(char_u *menu_path)
27822782
return menu;
27832783
}
27842784

2785+
void
2786+
set_mac_menu_attrs(
2787+
vimmenu_T *menu,
2788+
char_u *action,
2789+
int set_alt,
2790+
int mac_alternate,
2791+
int set_key,
2792+
int mac_key,
2793+
int mac_mods)
2794+
{
2795+
if (action)
2796+
menu->mac_action = action;
2797+
if (set_key)
2798+
{
2799+
menu->mac_key = mac_key;
2800+
menu->mac_mods = mac_mods;
2801+
}
2802+
if (set_alt)
2803+
menu->mac_alternate = mac_alternate;
2804+
}
2805+
27852806
/*
27862807
* Handle the ":macmenu" command.
27872808
*/
@@ -2790,11 +2811,14 @@ ex_macmenu(eap)
27902811
exarg_T *eap;
27912812
{
27922813
vimmenu_T *menu = NULL;
2814+
vimmenu_T *popup_menu_for_mode = NULL;
27932815
char_u *arg;
27942816
char_u *menu_path;
27952817
char_u *p;
27962818
char_u *keys;
2819+
int i;
27972820
int len;
2821+
int modes;
27982822
char_u *linep;
27992823
char_u *key_start;
28002824
char_u *key = NULL;
@@ -2804,9 +2828,10 @@ ex_macmenu(eap)
28042828
int mac_key = 0;
28052829
int mac_mods = 0;
28062830
int mac_alternate = 0;
2831+
int noremap;
2832+
int unmenu;
28072833
char_u *last_dash;
28082834
int bit;
2809-
int set_action = FALSE;
28102835
int set_key = FALSE;
28112836
int set_alt = FALSE;
28122837

@@ -2904,7 +2929,6 @@ ex_macmenu(eap)
29042929
break;
29052930
}
29062931

2907-
set_action = TRUE;
29082932
}
29092933
else if (STRCMP(key, "ALT") == 0)
29102934
{
@@ -3020,15 +3044,23 @@ ex_macmenu(eap)
30203044
*/
30213045
if (!error)
30223046
{
3023-
if (set_action)
3024-
menu->mac_action = action;
3025-
if (set_key)
3047+
set_mac_menu_attrs(menu, action, set_alt, mac_alternate, set_key, mac_key, mac_mods);
3048+
3049+
modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu);
3050+
if (menu_is_popup(menu_path))
30263051
{
3027-
menu->mac_key = mac_key;
3028-
menu->mac_mods = mac_mods;
3052+
for (i = 0; i < MENU_INDEX_TIP; ++i)
3053+
if (modes & (1 << i))
3054+
{
3055+
p = popup_mode_name(menu_path, i);
3056+
if (p != NULL)
3057+
{
3058+
popup_menu_for_mode = menu_for_path(p);
3059+
set_mac_menu_attrs(popup_menu_for_mode, action, set_alt, mac_alternate, set_key, mac_key, mac_mods);
3060+
vim_free(p);
3061+
}
3062+
}
30293063
}
3030-
if (set_alt)
3031-
menu->mac_alternate = mac_alternate;
30323064
}
30333065
else
30343066
{

0 commit comments

Comments
 (0)