mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
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)
f42b45d719
This commit is contained in:
@ -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
|
||||
|
@ -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"));
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user