diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-06-30 19:54:03 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-07-01 10:17:39 +0800 |
commit | d81d8d454a151c60f4281c904e387661712b7984 (patch) | |
tree | 119550101bf02121347d12e35959bf65049a2fde | |
parent | 015778a3817178a8fdc1150ef1b0eaa3dde776f1 (diff) | |
download | rneovim-d81d8d454a151c60f4281c904e387661712b7984.tar.gz rneovim-d81d8d454a151c60f4281c904e387661712b7984.tar.bz2 rneovim-d81d8d454a151c60f4281c904e387661712b7984.zip |
vim-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 vim/vim#3765)
https://github.com/vim/vim/commit/f42b45d719e03218735b3c2845a74dca9c0efd60
-rw-r--r-- | runtime/doc/gui.txt | 4 | ||||
-rw-r--r-- | src/nvim/globals.h | 1 | ||||
-rw-r--r-- | src/nvim/menu.c | 5 | ||||
-rw-r--r-- | src/nvim/popupmnu.c | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 20 |
5 files changed, 30 insertions, 7 deletions
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index b3b8b2d2c0..5badd954d9 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -508,7 +508,9 @@ may be used to complete the name of the menu item for the appropriate mode. 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 + :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 diff --git a/src/nvim/globals.h b/src/nvim/globals.h index a2862edd6b..d2f56c739b 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -986,6 +986,7 @@ EXTERN char e_notset[] INIT(= N_("E764: Option '%s' is not set")); EXTERN char e_invalidreg[] INIT(= N_("E850: Invalid register name")); EXTERN char e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); EXTERN char e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior")); +EXTERN char e_menuothermode[] INIT(= N_("E328: Menu only exists in another mode")); EXTERN char e_autocmd_close[] INIT(= N_("E813: Cannot close autocmd window")); EXTERN char e_listarg[] INIT(= N_("E686: Argument of %s must be a List")); EXTERN char e_unsupportedoption[] INIT(= N_("E519: Option not supported")); diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 34df096709..dbe8e1b2fe 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -41,7 +41,6 @@ static char *menu_mode_chars[] = { "n", "v", "s", "o", "i", "c", "tl", "t" }; static char e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu"); -static char e_othermode[] = N_("E328: Menu only exists in another mode"); static char e_nomenu[] = N_("E329: No menu \"%s\""); // Return true if "name" is a window toolbar menu name. @@ -573,7 +572,7 @@ static int remove_menu(vimmenu_T **menup, char *name, int modes, bool silent) } } else if (*name != NUL) { if (!silent) { - emsg(_(e_othermode)); + emsg(_(e_menuothermode)); } return FAIL; } @@ -787,7 +786,7 @@ static vimmenu_T *find_menu(vimmenu_T *menu, char *name, int modes) emsg(_(e_notsubmenu)); return NULL; } else if ((menu->modes & modes) == 0x0) { - emsg(_(e_othermode)); + emsg(_(e_menuothermode)); return NULL; } else if (*p == NUL) { // found a full match return menu; diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index a34faa8fcc..befed415a6 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -1008,6 +1008,13 @@ void pum_show_popupmenu(vimmenu_T *menu) } } + // When there are only Terminal mode menus, using "popup Edit" results in + // pum_size being zero. + if (pum_size <= 0) { + emsg(e_menuothermode); + return; + } + int idx = 0; pumitem_T *array = (pumitem_T *)xcalloc((size_t)pum_size, sizeof(pumitem_T)); diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 9a31f61582..48358f71b8 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -913,7 +913,7 @@ func Test_popup_complete_backwards_ctrl_p() bwipe! endfunc -fun! Test_complete_o_tab() +func Test_complete_o_tab() CheckFunction test_override let s:o_char_pressed = 0 @@ -922,7 +922,7 @@ fun! Test_complete_o_tab() let s:o_char_pressed = 0 call feedkeys("\<c-x>\<c-n>", 'i') endif - endf + endfunc set completeopt=menu,noselect new @@ -941,7 +941,21 @@ fun! Test_complete_o_tab() bwipe! set completeopt& delfunc s:act_on_text_changed -endf +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 func Test_popup_complete_info_01() new |