mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.1.1274: after :unmenu can still execute the menu with :emenu
Problem: After :unmenu can still execute the menu with :emenu. Solution: Do not execute a menu that was disabled for the specified mode.
This commit is contained in:
@@ -2337,7 +2337,8 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
|
|||||||
if (idx == -1 || eap == NULL)
|
if (idx == -1 || eap == NULL)
|
||||||
idx = MENU_INDEX_NORMAL;
|
idx = MENU_INDEX_NORMAL;
|
||||||
|
|
||||||
if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL)
|
if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL
|
||||||
|
&& (menu->modes & (1 << idx)))
|
||||||
{
|
{
|
||||||
/* When executing a script or function execute the commands right now.
|
/* When executing a script or function execute the commands right now.
|
||||||
* Also for the window toolbar.
|
* Also for the window toolbar.
|
||||||
|
@@ -54,8 +54,23 @@ func Test_menu_commands()
|
|||||||
emenu c Test.FooBar
|
emenu c Test.FooBar
|
||||||
call assert_equal('cmdline', g:did_menu)
|
call assert_equal('cmdline', g:did_menu)
|
||||||
|
|
||||||
aunmenu Test.FooBar
|
nunmenu Test.FooBar
|
||||||
|
call assert_fails('emenu n Test.FooBar', 'E335: Menu not defined for Normal mode')
|
||||||
|
vunmenu Test.FooBar
|
||||||
|
call assert_fails('emenu v Test.FooBar', 'E335: Menu not defined for Visual mode')
|
||||||
|
vmenu 2 Test.FooBar :let g:did_menu = 'visual'<CR>
|
||||||
|
sunmenu Test.FooBar
|
||||||
|
call assert_fails('emenu s Test.FooBar', 'E335: Menu not defined for Select mode')
|
||||||
|
ounmenu Test.FooBar
|
||||||
|
call assert_fails('emenu o Test.FooBar', 'E335: Menu not defined for Op-pending mode')
|
||||||
|
iunmenu Test.FooBar
|
||||||
|
call assert_fails('emenu i Test.FooBar', 'E335: Menu not defined for Insert mode')
|
||||||
|
cunmenu Test.FooBar
|
||||||
|
call assert_fails('emenu c Test.FooBar', 'E335: Menu not defined for Cmdline mode')
|
||||||
tlunmenu Test.FooBar
|
tlunmenu Test.FooBar
|
||||||
|
call assert_fails('emenu t Test.FooBar', 'E335: Menu not defined for Terminal mode')
|
||||||
|
|
||||||
|
aunmenu Test.FooBar
|
||||||
call assert_fails('emenu n Test.FooBar', 'E334:')
|
call assert_fails('emenu n Test.FooBar', 'E334:')
|
||||||
|
|
||||||
nmenu 2 Test.FooBar.Child :let g:did_menu = 'foobar'<CR>
|
nmenu 2 Test.FooBar.Child :let g:did_menu = 'foobar'<CR>
|
||||||
|
@@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1274,
|
||||||
/**/
|
/**/
|
||||||
1273,
|
1273,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user