To: vim_dev@googlegroups.com Subject: Patch 8.1.06 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0695 Problem: Internal error when using :popup. Solution: When a menu only exists in Terminal mode give an error. (Naruhiko Nishino, closes #3765) Files: runtime/doc/gui.txt, src/globals.h, src/menu.c, src/popupmnu.c, src/testdir/test_popup.vim *** ../vim-8.1.0694/runtime/doc/gui.txt 2018-10-19 22:35:04.885189994 +0200 --- runtime/doc/gui.txt 2019-01-06 13:03:08.707558482 +0100 *************** *** 878,884 **** 't': |:tlmenu| Terminal mode 'i': |:imenu| Insert mode 'c': |:cmenu| Cmdline mode ! If the console-mode vim has been compiled with WANT_MENU defined, you can use :emenu to access useful menu items you may have got used to from GUI --- 878,884 ---- 't': |:tlmenu| Terminal mode 'i': |:imenu| Insert mode 'c': |:cmenu| Cmdline mode ! If the console-mode vim has been compiled with WANT_MENU defined, you can use :emenu to access useful menu items you may have got used to from GUI *************** *** 914,920 **** To remove all menus use: *:unmenu-all* > :unmenu * " remove all menus in Normal and visual mode :unmenu! * " remove all menus in Insert and Command-line mode ! :aunmenu * " remove all menus in all modes If you want to get rid of the menu bar: > :set guioptions-=m --- 914,922 ---- To remove all menus use: *:unmenu-all* > :unmenu * " remove all menus in Normal and visual mode :unmenu! * " remove all menus in Insert and Command-line mode ! :aunmenu * " remove all menus in all modes, except for Terminal ! " mode ! :tlunmenu * " remove all menus in Terminal mode If you want to get rid of the menu bar: > :set guioptions-=m *** ../vim-8.1.0694/src/globals.h 2019-01-02 23:47:14.360433274 +0100 --- src/globals.h 2019-01-06 13:04:18.315075186 +0100 *************** *** 1583,1588 **** --- 1583,1591 ---- #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); *** ../vim-8.1.0694/src/menu.c 2018-10-19 22:35:04.885189994 +0200 --- src/menu.c 2019-01-06 13:04:44.590892904 +0100 *************** *** 61,67 **** 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 --- 61,66 ---- *************** *** 956,962 **** else if (*name != NUL) { if (!silent) ! EMSG(_(e_othermode)); return FAIL; } --- 955,961 ---- else if (*name != NUL) { if (!silent) ! EMSG(_(e_menuothermode)); return FAIL; } *************** *** 1130,1136 **** } else if ((menu->modes & modes) == 0x0) { ! EMSG(_(e_othermode)); vim_free(path_name); return FAIL; } --- 1129,1135 ---- } else if ((menu->modes & modes) == 0x0) { ! EMSG(_(e_menuothermode)); vim_free(path_name); return FAIL; } *** ../vim-8.1.0694/src/popupmnu.c 2018-12-31 22:09:53.106187962 +0100 --- src/popupmnu.c 2019-01-06 13:06:14.690268391 +0100 *************** *** 1195,1200 **** --- 1195,1208 ---- || (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; *** ../vim-8.1.0694/src/testdir/test_popup.vim 2018-12-01 11:58:44.415064948 +0100 --- src/testdir/test_popup.vim 2019-01-06 13:00:33.244640253 +0100 *************** *** 882,886 **** --- 882,899 ---- 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"+gP "+ + 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 *** ../vim-8.1.0694/src/version.c 2019-01-06 12:54:51.823033166 +0100 --- src/version.c 2019-01-06 13:09:53.512833815 +0100 *************** *** 801,802 **** --- 801,804 ---- { /* Add new patch number below this line */ + /**/ + 695, /**/ -- hundred-and-one symptoms of being an internet addict: 111. You and your friends get together regularly on IRC, even though all of you live in the same city. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///