Patch 8.1.1849
problem:    Some insert complete functions in the wrong file.
Solution:   Move complete functions to insexpand.c. (Yegappan Lakshmanan,
            closes #4815)
Files:      src/evalfunc.c, src/insexpand.c, src/proto/insexpand.pro


*** ../vim-8.1.1848/src/evalfunc.c      2019-08-10 22:21:43.001777985 +0200
--- src/evalfunc.c      2019-08-15 21:21:59.228271355 +0200
***************
*** 75,86 ****
  static void f_chdir(typval_T *argvars, typval_T *rettv);
  static void f_cindent(typval_T *argvars, typval_T *rettv);
  static void f_col(typval_T *argvars, typval_T *rettv);
- #if defined(FEAT_INS_EXPAND)
- static void f_complete(typval_T *argvars, typval_T *rettv);
- static void f_complete_add(typval_T *argvars, typval_T *rettv);
- static void f_complete_check(typval_T *argvars, typval_T *rettv);
- static void f_complete_info(typval_T *argvars, typval_T *rettv);
- #endif
  static void f_confirm(typval_T *argvars, typval_T *rettv);
  static void f_copy(typval_T *argvars, typval_T *rettv);
  #ifdef FEAT_FLOAT
--- 75,80 ----
***************
*** 2294,2379 ****
      rettv->vval.v_number = col;
  }
  
- #if defined(FEAT_INS_EXPAND)
- /*
-  * "complete()" function
-  */
-     static void
- f_complete(typval_T *argvars, typval_T *rettv UNUSED)
- {
-     int           startcol;
- 
-     if ((State & INSERT) == 0)
-     {
-       emsg(_("E785: complete() can only be used in Insert mode"));
-       return;
-     }
- 
-     /* Check for undo allowed here, because if something was already inserted
-      * the line was already saved for undo and this check isn't done. */
-     if (!undo_allowed())
-       return;
- 
-     if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
-     {
-       emsg(_(e_invarg));
-       return;
-     }
- 
-     startcol = (int)tv_get_number_chk(&argvars[0], NULL);
-     if (startcol <= 0)
-       return;
- 
-     set_completion(startcol - 1, argvars[1].vval.v_list);
- }
- 
- /*
-  * "complete_add()" function
-  */
-     static void
- f_complete_add(typval_T *argvars, typval_T *rettv)
- {
-     rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0);
- }
- 
- /*
-  * "complete_check()" function
-  */
-     static void
- f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
- {
-     int               saved = RedrawingDisabled;
- 
-     RedrawingDisabled = 0;
-     ins_compl_check_keys(0, TRUE);
-     rettv->vval.v_number = ins_compl_interrupted();
-     RedrawingDisabled = saved;
- }
- 
- /*
-  * "complete_info()" function
-  */
-     static void
- f_complete_info(typval_T *argvars, typval_T *rettv)
- {
-     list_T    *what_list = NULL;
- 
-     if (rettv_dict_alloc(rettv) != OK)
-       return;
- 
-     if (argvars[0].v_type != VAR_UNKNOWN)
-     {
-       if (argvars[0].v_type != VAR_LIST)
-       {
-           emsg(_(e_listreq));
-           return;
-       }
-       what_list = argvars[0].vval.v_list;
-     }
-     get_complete_info(what_list, rettv->vval.v_dict);
- }
- #endif
- 
  /*
   * "confirm(message, buttons[, default [, type]])" function
   */
--- 2288,2293 ----
*** ../vim-8.1.1848/src/insexpand.c     2019-07-28 16:36:31.673949528 +0200
--- src/insexpand.c     2019-08-15 21:21:59.228271355 +0200
***************
*** 859,865 ****
   * "startcol" is where the matched text starts (1 is first column).
   * "list" is the list of matches.
   */
!     void
  set_completion(colnr_T startcol, list_T *list)
  {
      int save_w_wrow = curwin->w_wrow;
--- 859,865 ----
   * "startcol" is where the matched text starts (1 is first column).
   * "list" is the list of matches.
   */
!     static void
  set_completion(colnr_T startcol, list_T *list)
  {
      int save_w_wrow = curwin->w_wrow;
***************
*** 1522,1528 ****
  /*
   * Get complete information
   */
!     void
  get_complete_info(list_T *what_list, dict_T *retdict)
  {
      int               ret = OK;
--- 1522,1528 ----
  /*
   * Get complete information
   */
!     static void
  get_complete_info(list_T *what_list, dict_T *retdict)
  {
      int               ret = OK;
***************
*** 2353,2358 ****
--- 2353,2407 ----
  
  #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) || defined(PROTO)
  /*
+  * Add a match to the list of matches from a typeval_T.
+  * If the given string is already in the list of completions, then return
+  * NOTDONE, otherwise add it to the list and return OK.  If there is an error,
+  * maybe because alloc() returns NULL, then FAIL is returned.
+  */
+     static int
+ ins_compl_add_tv(typval_T *tv, int dir)
+ {
+     char_u    *word;
+     int               dup = FALSE;
+     int               empty = FALSE;
+     int               flags = 0;
+     char_u    *(cptext[CPT_COUNT]);
+ 
+     if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
+     {
+       word = dict_get_string(tv->vval.v_dict, (char_u *)"word", FALSE);
+       cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict,
+                                                    (char_u *)"abbr", FALSE);
+       cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict,
+                                                    (char_u *)"menu", FALSE);
+       cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict,
+                                                    (char_u *)"kind", FALSE);
+       cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict,
+                                                    (char_u *)"info", FALSE);
+       cptext[CPT_USER_DATA] = dict_get_string(tv->vval.v_dict,
+                                                (char_u *)"user_data", FALSE);
+       if (dict_get_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL
+                       && dict_get_number(tv->vval.v_dict, (char_u *)"icase"))
+           flags |= CP_ICASE;
+       if (dict_get_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL)
+           dup = dict_get_number(tv->vval.v_dict, (char_u *)"dup");
+       if (dict_get_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL)
+           empty = dict_get_number(tv->vval.v_dict, (char_u *)"empty");
+       if (dict_get_string(tv->vval.v_dict, (char_u *)"equal", FALSE) != NULL
+                       && dict_get_number(tv->vval.v_dict, (char_u *)"equal"))
+           flags |= CP_EQUAL;
+     }
+     else
+     {
+       word = tv_get_string_chk(tv);
+       vim_memset(cptext, 0, sizeof(cptext));
+     }
+     if (word == NULL || (!empty && *word == NUL))
+       return FAIL;
+     return ins_compl_add(word, -1, NULL, cptext, dir, flags, dup);
+ }
+ 
+ /*
   * Add completions from a list.
   */
      static void
***************
*** 2399,2450 ****
  }
  
  /*
!  * Add a match to the list of matches from a typeval_T.
!  * If the given string is already in the list of completions, then return
!  * NOTDONE, otherwise add it to the list and return OK.  If there is an error,
!  * maybe because alloc() returns NULL, then FAIL is returned.
   */
!     int
! ins_compl_add_tv(typval_T *tv, int dir)
  {
!     char_u    *word;
!     int               dup = FALSE;
!     int               empty = FALSE;
!     int               flags = 0;
!     char_u    *(cptext[CPT_COUNT]);
  
!     if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
      {
!       word = dict_get_string(tv->vval.v_dict, (char_u *)"word", FALSE);
!       cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict,
!                                                    (char_u *)"abbr", FALSE);
!       cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict,
!                                                    (char_u *)"menu", FALSE);
!       cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict,
!                                                    (char_u *)"kind", FALSE);
!       cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict,
!                                                    (char_u *)"info", FALSE);
!       cptext[CPT_USER_DATA] = dict_get_string(tv->vval.v_dict,
!                                                (char_u *)"user_data", FALSE);
!       if (dict_get_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL
!                       && dict_get_number(tv->vval.v_dict, (char_u *)"icase"))
!           flags |= CP_ICASE;
!       if (dict_get_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL)
!           dup = dict_get_number(tv->vval.v_dict, (char_u *)"dup");
!       if (dict_get_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL)
!           empty = dict_get_number(tv->vval.v_dict, (char_u *)"empty");
!       if (dict_get_string(tv->vval.v_dict, (char_u *)"equal", FALSE) != NULL
!                       && dict_get_number(tv->vval.v_dict, (char_u *)"equal"))
!           flags |= CP_EQUAL;
      }
!     else
      {
!       word = tv_get_string_chk(tv);
!       vim_memset(cptext, 0, sizeof(cptext));
      }
!     if (word == NULL || (!empty && *word == NUL))
!       return FAIL;
!     return ins_compl_add(word, -1, NULL, cptext, dir, flags, dup);
  }
  #endif
  
--- 2448,2528 ----
  }
  
  /*
!  * "complete()" function
   */
!     void
! f_complete(typval_T *argvars, typval_T *rettv UNUSED)
  {
!     int           startcol;
  
!     if ((State & INSERT) == 0)
      {
!       emsg(_("E785: complete() can only be used in Insert mode"));
!       return;
      }
! 
!     // Check for undo allowed here, because if something was already inserted
!     // the line was already saved for undo and this check isn't done.
!     if (!undo_allowed())
!       return;
! 
!     if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
      {
!       emsg(_(e_invarg));
!       return;
      }
! 
!     startcol = (int)tv_get_number_chk(&argvars[0], NULL);
!     if (startcol <= 0)
!       return;
! 
!     set_completion(startcol - 1, argvars[1].vval.v_list);
! }
! 
! /*
!  * "complete_add()" function
!  */
!     void
! f_complete_add(typval_T *argvars, typval_T *rettv)
! {
!     rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0);
! }
! 
! /*
!  * "complete_check()" function
!  */
!     void
! f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
! {
!     int               saved = RedrawingDisabled;
! 
!     RedrawingDisabled = 0;
!     ins_compl_check_keys(0, TRUE);
!     rettv->vval.v_number = ins_compl_interrupted();
!     RedrawingDisabled = saved;
! }
! 
! /*
!  * "complete_info()" function
!  */
!     void
! f_complete_info(typval_T *argvars, typval_T *rettv)
! {
!     list_T    *what_list = NULL;
! 
!     if (rettv_dict_alloc(rettv) != OK)
!       return;
! 
!     if (argvars[0].v_type != VAR_UNKNOWN)
!     {
!       if (argvars[0].v_type != VAR_LIST)
!       {
!           emsg(_(e_listreq));
!           return;
!       }
!       what_list = argvars[0].vval.v_list;
!     }
!     get_complete_info(what_list, rettv->vval.v_dict);
  }
  #endif
  
*** ../vim-8.1.1848/src/proto/insexpand.pro     2019-04-06 14:22:17.754642647 
+0200
--- src/proto/insexpand.pro     2019-08-15 21:21:59.232271336 +0200
***************
*** 24,37 ****
  int ins_compl_has_shown_match(void);
  int ins_compl_long_shown_match(void);
  void completeopt_was_set(void);
- void set_completion(colnr_T startcol, list_T *list);
  int pum_wanted(void);
  void ins_compl_show_pum(void);
  char_u *find_word_start(char_u *ptr);
  char_u *find_word_end(char_u *ptr);
  void ins_compl_clear(void);
  int ins_compl_active(void);
- void get_complete_info(list_T *what_list, dict_T *retdict);
  int ins_compl_used_match(void);
  void ins_compl_init_get_longest(void);
  int ins_compl_interrupted(void);
--- 24,35 ----
***************
*** 41,47 ****
  void ins_compl_addleader(int c);
  void ins_compl_addfrommatch(void);
  int ins_compl_prep(int c);
! int ins_compl_add_tv(typval_T *tv, int dir);
  void ins_compl_delete(void);
  void ins_compl_insert(int in_compl_func);
  void ins_compl_check_keys(int frequency, int in_compl_func);
--- 39,48 ----
  void ins_compl_addleader(int c);
  void ins_compl_addfrommatch(void);
  int ins_compl_prep(int c);
! void f_complete(typval_T *argvars, typval_T *rettv);
! void f_complete_add(typval_T *argvars, typval_T *rettv);
! void f_complete_check(typval_T *argvars, typval_T *rettv);
! void f_complete_info(typval_T *argvars, typval_T *rettv);
  void ins_compl_delete(void);
  void ins_compl_insert(int in_compl_func);
  void ins_compl_check_keys(int frequency, int in_compl_func);
*** ../vim-8.1.1848/src/version.c       2019-08-15 20:58:49.818081278 +0200
--- src/version.c       2019-08-15 21:23:22.691916327 +0200
***************
*** 771,772 ****
--- 771,774 ----
  {   /* Add new patch number below this line */
+ /**/
+     1849,
  /**/

-- 
Creating the world with Emacs:   M-x let-there-be-light
Creating the world with Vim:     :make world

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201908151933.x7FJXdAh011296%40masaka.moolenaar.net.

Raspunde prin e-mail lui