neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 1a4753f25a0efe6f79aed6d3bf10d4459ae302bd
parent cbfae548e8944801e766f42d966b38491afa8587
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Tue, 26 Jul 2022 20:03:02 +0800

Merge pull request #19514 from zeertzjq/vim-8.1.1424

vim-patch:8.1.1424,9.0.0076: crash when popup menu is deleted while waiting for char
Diffstat:
Msrc/nvim/popupmnu.c | 5++++-
Msrc/nvim/testdir/test_popup.vim | 19+++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c @@ -1054,7 +1054,10 @@ void pum_show_popupmenu(vimmenu_T *menu) ui_flush(); int c = vgetc(); - if (c == ESC || c == Ctrl_C) { + + // Bail out when typing Esc, CTRL-C or some callback or <expr> mapping + // closed the popup menu. + if (c == ESC || c == Ctrl_C || pum_array == NULL) { break; } else if (c == CAR || c == NL) { // enter: select current item, if any, and close diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim @@ -955,6 +955,25 @@ func Test_menu_only_exists_in_terminal() endtry endfunc +" This used to crash before patch 8.1.1424 +func Test_popup_delete_when_shown() + CheckFeature menu + CheckNotGui + + func Func() + popup Foo + return "\<Ignore>" + endfunc + + nmenu Foo.Bar : + nnoremap <expr> <F2> Func() + call feedkeys("\<F2>\<F2>\<Esc>", 'xt') + + delfunc Func + nunmenu Foo.Bar + nunmap <F2> +endfunc + func Test_popup_complete_info_01() new inoremap <buffer><F5> <C-R>=complete_info().mode<CR>