diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-06-25 18:38:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-25 18:38:35 +0800 |
commit | a5175fe48934522e3a82fe22bc5f7ee9c3d5f7dd (patch) | |
tree | f45b16eb90044f9edd427aadf0b3896dee066a73 /src | |
parent | 5c2c88717a9d32df3b59065397d9ee7c357491b4 (diff) | |
download | rneovim-a5175fe48934522e3a82fe22bc5f7ee9c3d5f7dd.tar.gz rneovim-a5175fe48934522e3a82fe22bc5f7ee9c3d5f7dd.tar.bz2 rneovim-a5175fe48934522e3a82fe22bc5f7ee9c3d5f7dd.zip |
vim-patch:8.2.5022: 'completefunc'/'omnifunc' error does not end completion (#19083)
Problem: 'completefunc'/'omnifunc' error does not end completion.
Solution: Check if there was an error or exception. (closes vim/vim#10486,
closes vim/vim#4218)
https://github.com/vim/vim/commit/9bcb9ca9c7dd1632385dc3351b5e019739368658
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/edit.c | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_ins_complete.vim | 24 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index e0717ef8bc..47d07e457f 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -5263,12 +5263,13 @@ static int ins_complete(int c, bool enable_pum) return FAIL; } - /* Return value -2 means the user complete function wants to - * cancel the complete without an error. - * Return value -3 does the same as -2 and leaves CTRL-X mode.*/ - if (col == -2) { + // Return value -2 means the user complete function wants to cancel the + // complete without an error, do the same if the function did not execute + // successfully. + if (col == -2 || aborting()) { return FAIL; } + // Return value -3 does the same as -2 and leaves CTRL-X mode. if (col == -3) { ctrl_x_mode = CTRL_X_NORMAL; edit_submode = NULL; diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 90b57323af..c8104c6b73 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -287,6 +287,30 @@ func Test_omni_dash() set omnifunc= endfunc +func Test_omni_throw() + let g:CallCount = 0 + func Omni(findstart, base) + let g:CallCount += 1 + if a:findstart + throw "he he he" + endif + endfunc + set omnifunc=Omni + new + try + exe "normal ifoo\<C-x>\<C-o>" + call assert_false(v:true, 'command should have failed') + catch + call assert_exception('he he he') + call assert_equal(1, g:CallCount) + endtry + + bwipe! + delfunc Omni + unlet g:CallCount + set omnifunc= +endfunc + func Test_completefunc_args() let s:args = [] func! CompleteFunc(findstart, base) |