macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.47k stars 680 forks source link

Fix :emenu crash when it's associated with a macaction in a non-valid mode #1305

Closed ychin closed 1 year ago

ychin commented 1 year ago

The existing emenu code has this odd exception where if you invoke it on a menu with bound in Vim, and has a macaction, it will call the macaction instead. However, it's not properly handling the situation when the menu is not bound for the mode and would crash when deferencing a null string ptr. Move it to the proper spot and fix up a previous upstream merge mistake (in Vim upstream, when you call :emenu on a menu item it just does nothing now, instead of complaining about it) so that it all works correctly.