Skip to content

Instantly share code, notes, and snippets.

@rbtnn
Last active January 4, 2019 23:16
Show Gist options
  • Save rbtnn/9b85eae581f80f3b86082bd561782895 to your computer and use it in GitHub Desktop.
Save rbtnn/9b85eae581f80f3b86082bd561782895 to your computer and use it in GitHub Desktop.
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index 565f8a518..bf7db8054 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -916,6 +916,9 @@ To remove all menus use: *:unmenu-all* >
:unmenu! * " remove all menus in Insert and Command-line mode
:aunmenu * " remove all menus in all modes
+Note |:aunmenu| is to remove all menus in all modes, except for Terminal mode.
+To remove menus for Terminal mode, use |:tlunmenu| instead.
+
If you want to get rid of the menu bar: >
:set guioptions-=m
diff --git a/src/globals.h b/src/globals.h
index 2a7ecd17b..e4908d8ed 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1595,6 +1595,10 @@ EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP"));
EXTERN char need_key_msg[] INIT(= N_("Need encryption key for \"%s\""));
#endif
+#ifdef FEAT_MENU
+EXTERN char_u e_menuothermode[] INIT(= N_("E328: Menu only exists in another mode"));
+#endif
+
/*
* Comms. with the session manager (XSMP)
*/
diff --git a/src/menu.c b/src/menu.c
index 782235a11..944211844 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -61,7 +61,6 @@ static char_u *menu_translate_tab_and_shift(char_u *arg_start);
static char *menu_mode_chars[] = {"n", "v", "s", "o", "i", "c", "tl", "t"};
static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu");
-static char_u e_othermode[] = N_("E328: Menu only exists in another mode");
static char_u e_nomenu[] = N_("E329: No menu \"%s\"");
#ifdef FEAT_TOOLBAR
@@ -956,7 +955,7 @@ remove_menu(
else if (*name != NUL)
{
if (!silent)
- EMSG(_(e_othermode));
+ EMSG(_(e_menuothermode));
return FAIL;
}
@@ -1130,7 +1129,7 @@ show_menus(char_u *path_name, int modes)
}
else if ((menu->modes & modes) == 0x0)
{
- EMSG(_(e_othermode));
+ EMSG(_(e_menuothermode));
vim_free(path_name);
return FAIL;
}
diff --git a/src/popupmnu.c b/src/popupmnu.c
index 6ef0af92a..ae2ab29f7 100644
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -1195,6 +1195,15 @@ pum_show_popupmenu(vimmenu_T *menu)
|| (mp->modes & mp->enabled & mode))
++pum_size;
+ /* executing 'tlnoremap ...', 'aunmenu *' and 'popup Edit', pum_size is 0.
+ * because 'aunmenu *' is excluding Terminal mode.
+ */
+ if (pum_size <= 0)
+ {
+ EMSG(e_menuothermode);
+ return;
+ }
+
array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size);
if (array == NULL)
return;
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index 287d59d90..f4c5b98e3 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -882,5 +882,17 @@ func Test_complete_o_tab()
delfunc s:act_on_text_changed
endfunc
+func Test_menu_only_exists_in_terminal()
+ if exists(':tlmenu')
+ tlnoremenu &Edit.&Paste<Tab>"+gP <C-W>"+
+ aunmenu *
+ try
+ popup Edit
+ call assert_false(1, 'command should have failed')
+ catch
+ call assert_exception('E973:')
+ endtry
+ endif
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment