]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0123: complete_info() does not work when CompleteDone is triggered v8.2.0123
authorBram Moolenaar <Bram@vim.org>
Fri, 17 Jan 2020 17:58:59 +0000 (18:58 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 17 Jan 2020 17:58:59 +0000 (18:58 +0100)
Problem:    complete_info() does not work when CompleteDone is triggered.
Solution:   Trigger CompleteDone before clearing the info.

runtime/doc/autocmd.txt
src/insexpand.c
src/testdir/test_ins_complete.vim
src/version.c

index 8ae0a4ec4cf174f00c978a7b9f7a80427310ef2f..89ba5750d4cbf51ebec00afae05068a4fecc2166 100644 (file)
@@ -1,4 +1,4 @@
-*autocmd.txt*   For Vim version 8.2.  Last change: 2019 Dec 17
+*autocmd.txt*   For Vim version 8.2.  Last change: 2020 Jan 17
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -610,6 +610,8 @@ CompleteChanged                                             *CompleteChanged*
 CompleteDone                   After Insert mode completion is done.  Either
                                when something was completed or abandoning
                                completion. |ins-completion|
+                               |complete_info()| can be used, the info is
+                               cleared after triggering CompleteDone.
                                The |v:completed_item| variable contains
                                information about the completed item.
 
index acddd2658cf213a11cb1832cc40f6e600be2f7dc..54f8cb35122c8376b6b339b203c213039b7dd856 100644 (file)
@@ -1813,6 +1813,7 @@ ins_compl_prep(int c)
     int                want_cindent;
 #endif
     int                retval = FALSE;
+    int                prev_mode = ctrl_x_mode;
 
     // Forget any previous 'special' messages if this is actually
     // a ^X mode key - bar ^R, in which case we wait to see what it gives us.
@@ -2060,6 +2061,18 @@ ins_compl_prep(int c)
 
            auto_format(FALSE, TRUE);
 
+           {
+               int new_mode = ctrl_x_mode;
+
+               // Trigger the CompleteDone event to give scripts a chance to
+               // act upon the completion.  Do this before clearing the info,
+               // and restore ctrl_x_mode, so that complete_info() can be
+               // used.
+               ctrl_x_mode = prev_mode;
+               ins_apply_autocmds(EVENT_COMPLETEDONE);
+               ctrl_x_mode = new_mode;
+           }
+
            ins_compl_free();
            compl_started = FALSE;
            compl_matches = 0;
@@ -2084,9 +2097,6 @@ ins_compl_prep(int c)
            if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0)))
                do_c_expr_indent();
 #endif
-           // Trigger the CompleteDone event to give scripts a chance to act
-           // upon the completion.
-           ins_apply_autocmds(EVENT_COMPLETEDONE);
        }
     }
     else if (ctrl_x_mode == CTRL_X_LOCAL_MSG)
index c9d93ceb1e263496ad3138219432ee9e15b72d42..ef5ac72ae9fbba1f495175fae20386ad3788cd6e 100644 (file)
@@ -183,6 +183,8 @@ func s:CompleteDone_CheckCompletedItemDict()
   call assert_equal( 'W',              v:completed_item[ 'kind' ] )
   call assert_equal( 'test',           v:completed_item[ 'user_data' ] )
 
+  call assert_equal('function', complete_info().mode)
+
   let s:called_completedone = 1
 endfunc
 
index 737b5747a4a4116063da0f6a59930f3895dba98d..e3657bfd5971338414d23c938dd97d575613ef37 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    123,
 /**/
     122,
 /**/