summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2022-05-26 15:23:26 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-26 15:23:26 +0100
commit9bcb9ca9c7dd1632385dc3351b5e019739368658 (patch)
treedd0820db2970ea6a5264e17493937a75ca062a8e
parent30b9a41ad9963b8c57afea1f33a4e180fc23a892 (diff)
patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completionv8.2.5022
Problem: 'completefunc'/'omnifunc' error does not end completion. Solution: Check if there was an error or exception. (closes #10486, closes #4218)
-rw-r--r--src/insexpand.c9
-rw-r--r--src/testdir/test_ins_complete.vim24
-rw-r--r--src/version.c2
3 files changed, 31 insertions, 4 deletions
diff --git a/src/insexpand.c b/src/insexpand.c
index fd1218fd75..89e0ebd818 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -4522,11 +4522,12 @@ get_userdefined_compl_info(colnr_T curs_col UNUSED)
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;
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 6bb499701b..5ae89089d0 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -140,6 +140,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_omni_autoload()
let save_rtp = &rtp
set rtp=Xruntime/some
diff --git a/src/version.c b/src/version.c
index 058202d23d..9751865c7a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 5022,
+/**/
5021,
/**/
5020,