]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion v8.2.5022
authorLemonBoy <thatlemon@gmail.com>
Thu, 26 May 2022 14:23:26 +0000 (15:23 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 26 May 2022 14:23:26 +0000 (15:23 +0100)
Problem:    'completefunc'/'omnifunc' error does not end completion.
Solution:   Check if there was an error or exception. (closes #10486,
            closes #4218)

src/insexpand.c
src/testdir/test_ins_complete.vim
src/version.c

index fd1218fd75a87a0c0fbc2974be4c294662eee593..89e0ebd81888d13b748a91adbf065ec677dadce4 100644 (file)
@@ -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;
index 6bb499701b587ce6a943b4bf9a75601661ca5795..5ae89089d06b3fd0bb8eb0fa95958d76cd491e3d 100644 (file)
@@ -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
index 058202d23d1c5347705225b03c24ce7c5c54a8b0..9751865c7adfe1e2d7a2b69aa6c7b64eb36cd26d 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5022,
 /**/
     5021,
 /**/