@@ -2376,9 +2376,24 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
2376
2376
if (idx == MENU_INDEX_INVALID || eap == NULL )
2377
2377
idx = MENU_INDEX_NORMAL ;
2378
2378
2379
- if (menu -> strings [idx ] != NULL && menu -> strings [idx ][0 ] != NUL
2380
- && (menu -> modes & (1 << idx )))
2379
+ if (menu -> strings [idx ] != NULL && (menu -> modes & (1 << idx )))
2381
2380
{
2381
+ #ifdef FEAT_GUI_MACVIM
2382
+ // When a menu is bound to <Nop>, we let :emenu fall through to execute
2383
+ // the associated macaction (if one exists) instead. Otherwise, we
2384
+ // simply execute the associated Vim command. Note that if you
2385
+ // physically press the menu item (or the associated shortcut key), the
2386
+ // macaction is always invoked even if the menu isn't bound to <Nop>.
2387
+ if (menu -> mac_action != NULL && menu -> strings [idx ] != NULL && menu -> strings [idx ][0 ] == NUL )
2388
+ {
2389
+ // Count on the fact taht ex_macaction() only looks at eap->arg.
2390
+ old_arg = eap -> arg ;
2391
+ eap -> arg = menu -> mac_action ;
2392
+ ex_macaction (eap );
2393
+ eap -> arg = old_arg ;
2394
+ }
2395
+ #endif // FEAT_GUI_MACVIM
2396
+
2382
2397
// When executing a script or function execute the commands right now.
2383
2398
// Also for the window toolbar.
2384
2399
// Otherwise put them in the typeahead buffer.
@@ -2425,20 +2440,6 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
2425
2440
default :
2426
2441
mode = (char_u * )"Normal" ;
2427
2442
}
2428
- #ifdef FEAT_GUI_MACVIM
2429
- if (menu -> mac_action != NULL && menu -> strings [idx ][0 ] == NUL )
2430
- {
2431
- // This allows us to bind a menu to an action without mapping to
2432
- // anything so that pressing the menu's key equivalent and typing
2433
- // ":emenu ..." does the same thing. (HACK: We count on the fact
2434
- // that ex_macaction() only looks at eap->arg.)
2435
- old_arg = eap -> arg ;
2436
- eap -> arg = menu -> mac_action ;
2437
- ex_macaction (eap );
2438
- eap -> arg = old_arg ;
2439
- }
2440
- else
2441
- #endif // FEAT_GUI_MACVIM
2442
2443
semsg (_ (e_menu_not_defined_for_str_mode ), mode );
2443
2444
}
2444
2445
}
0 commit comments