diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-05 14:19:20 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-05 14:19:20 +0200 |
commit | ce79353ace9e21238f13655089363cd23cbb6b32 (patch) | |
tree | 468d76aa7641a5b926f37da1fcf0aec1f38ce645 /src | |
parent | f653a6bcff48161b56eeb3a584011aab6665f1e7 (diff) |
patch 8.1.1274: after :unmenu can still execute the menu with :emenuv8.1.1274
Problem: After :unmenu can still execute the menu with :emenu.
Solution: Do not execute a menu that was disabled for the specified mode.
Diffstat (limited to 'src')
-rw-r--r-- | src/menu.c | 3 | ||||
-rw-r--r-- | src/testdir/test_menu.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/menu.c b/src/menu.c index 21d3e11766..6e0c02ec3b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2337,7 +2337,8 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx) if (idx == -1 || eap == NULL) 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. * Also for the window toolbar. diff --git a/src/testdir/test_menu.vim b/src/testdir/test_menu.vim index 6462d5196c..b57fdc3de2 100644 --- a/src/testdir/test_menu.vim +++ b/src/testdir/test_menu.vim @@ -54,8 +54,23 @@ func Test_menu_commands() emenu c Test.FooBar 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 + 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:') nmenu 2 Test.FooBar.Child :let g:did_menu = 'foobar'<CR> diff --git a/src/version.c b/src/version.c index c8038f36f4..a2e23978db 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1274, +/**/ 1273, /**/ 1272, |