Skip to content

Commit f42b45d

Browse files
committed
patch 8.1.0695: internal error when using :popup
Problem: Internal error when using :popup. Solution: When a menu only exists in Terminal mode give an error. (Naruhiko Nishino, closes #3765)
1 parent 4614f53 commit f42b45d

6 files changed

Lines changed: 32 additions & 5 deletions

File tree

runtime/doc/gui.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*gui.txt* For Vim version 8.1. Last change: 2018 Mar 06
1+
*gui.txt* For Vim version 8.1. Last change: 2019 Jan 06
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -914,7 +914,9 @@ may be used to complete the name of the menu item for the appropriate mode.
914914
To remove all menus use: *:unmenu-all* >
915915
:unmenu * " remove all menus in Normal and visual mode
916916
:unmenu! * " remove all menus in Insert and Command-line mode
917-
:aunmenu * " remove all menus in all modes
917+
:aunmenu * " remove all menus in all modes, except for Terminal
918+
" mode
919+
:tlunmenu * " remove all menus in Terminal mode
918920
919921
If you want to get rid of the menu bar: >
920922
:set guioptions-=m

src/globals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,9 @@ EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name"));
15831583
#endif
15841584
EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\""));
15851585
EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
1586+
#ifdef FEAT_MENU
1587+
EXTERN char_u e_menuothermode[] INIT(= N_("E328: Menu only exists in another mode"));
1588+
#endif
15861589

15871590
#ifdef FEAT_GUI_MAC
15881591
EXTERN short disallow_gui INIT(= FALSE);

src/menu.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ static char_u *menu_translate_tab_and_shift(char_u *arg_start);
6161
static char *menu_mode_chars[] = {"n", "v", "s", "o", "i", "c", "tl", "t"};
6262

6363
static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu");
64-
static char_u e_othermode[] = N_("E328: Menu only exists in another mode");
6564
static char_u e_nomenu[] = N_("E329: No menu \"%s\"");
6665

6766
#ifdef FEAT_TOOLBAR
@@ -956,7 +955,7 @@ remove_menu(
956955
else if (*name != NUL)
957956
{
958957
if (!silent)
959-
EMSG(_(e_othermode));
958+
EMSG(_(e_menuothermode));
960959
return FAIL;
961960
}
962961

@@ -1130,7 +1129,7 @@ show_menus(char_u *path_name, int modes)
11301129
}
11311130
else if ((menu->modes & modes) == 0x0)
11321131
{
1133-
EMSG(_(e_othermode));
1132+
EMSG(_(e_menuothermode));
11341133
vim_free(path_name);
11351134
return FAIL;
11361135
}

src/popupmnu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,14 @@ pum_show_popupmenu(vimmenu_T *menu)
11951195
|| (mp->modes & mp->enabled & mode))
11961196
++pum_size;
11971197

1198+
// When there are only Terminal mode menus, using "popup Edit" results in
1199+
// pum_size being zero.
1200+
if (pum_size <= 0)
1201+
{
1202+
EMSG(e_menuothermode);
1203+
return;
1204+
}
1205+
11981206
array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size);
11991207
if (array == NULL)
12001208
return;

src/testdir/test_popup.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,5 +882,18 @@ func Test_complete_o_tab()
882882
delfunc s:act_on_text_changed
883883
endfunc
884884

885+
func Test_menu_only_exists_in_terminal()
886+
if !exists(':tlmenu') || has('gui_running')
887+
return
888+
endif
889+
tlnoremenu &Edit.&Paste<Tab>"+gP <C-W>"+
890+
aunmenu *
891+
try
892+
popup Edit
893+
call assert_false(1, 'command should have failed')
894+
catch
895+
call assert_exception('E328:')
896+
endtry
897+
endfunc
885898

886899
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,8 @@ static char *(features[]) =
799799

800800
static int included_patches[] =
801801
{ /* Add new patch number below this line */
802+
/**/
803+
695,
802804
/**/
803805
694,
804806
/**/

0 commit comments

Comments
 (0)