diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-06 13:11:05 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-06 13:11:05 +0100 |
commit | f42b45d719e03218735b3c2845a74dca9c0efd60 (patch) | |
tree | e5974454b590f16abc0aeafa523f4a710bdbf24e /src | |
parent | 4614f53e0f853b513963d1a639398348a571ecf1 (diff) | |
download | vim-git-f42b45d719e03218735b3c2845a74dca9c0efd60.tar.gz |
patch 8.1.0695: internal error when using :popupv8.1.0695
Problem: Internal error when using :popup.
Solution: When a menu only exists in Terminal mode give an error. (Naruhiko
Nishino, closes #3765)
Diffstat (limited to 'src')
-rw-r--r-- | src/globals.h | 3 | ||||
-rw-r--r-- | src/menu.c | 5 | ||||
-rw-r--r-- | src/popupmnu.c | 8 | ||||
-rw-r--r-- | src/testdir/test_popup.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 28 insertions, 3 deletions
diff --git a/src/globals.h b/src/globals.h index 2a7ecd17b..3f67d1377 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1583,6 +1583,9 @@ EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name")); #endif EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior")); +#ifdef FEAT_MENU +EXTERN char_u e_menuothermode[] INIT(= N_("E328: Menu only exists in another mode")); +#endif #ifdef FEAT_GUI_MAC EXTERN short disallow_gui INIT(= FALSE); 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..962a59a1b 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -1195,6 +1195,14 @@ pum_show_popupmenu(vimmenu_T *menu) || (mp->modes & mp->enabled & mode)) ++pum_size; + // When there are only Terminal mode menus, using "popup Edit" results in + // pum_size being zero. + 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..663a6a8e0 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -882,5 +882,18 @@ func Test_complete_o_tab() delfunc s:act_on_text_changed endfunc +func Test_menu_only_exists_in_terminal() + if !exists(':tlmenu') || has('gui_running') + return + endif + tlnoremenu &Edit.&Paste<Tab>"+gP <C-W>"+ + aunmenu * + try + popup Edit + call assert_false(1, 'command should have failed') + catch + call assert_exception('E328:') + endtry +endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 3450325e7..790c4f770 100644 --- a/src/version.c +++ b/src/version.c @@ -800,6 +800,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 695, +/**/ 694, /**/ 693, |