0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.0053: first argument of 'completefunc' has inconsistent type

Problem:    The first argument given to 'completefunc' can be Number or
            String, depending on the value.
Solution:   Avoid guessing the type of an argument, use typval_T in the
            callers of call_vim_function(). (Ozaki Kiichi, closes #2993)
This commit is contained in:
Bram Moolenaar
2018-06-12 22:05:14 +02:00
parent 83f4cbd973
commit ffa9684150
8 changed files with 86 additions and 89 deletions

View File

@@ -4201,7 +4201,7 @@ expand_by_function(
{
list_T *matchlist = NULL;
dict_T *matchdict = NULL;
char_u *args[2];
typval_T args[3];
char_u *funcname;
pos_T pos;
win_T *curwin_save;
@@ -4213,15 +4213,18 @@ expand_by_function(
return;
/* Call 'completefunc' to obtain the list of matches. */
args[0] = (char_u *)"0";
args[1] = base;
args[0].v_type = VAR_NUMBER;
args[0].vval.v_number = 0;
args[1].v_type = VAR_STRING;
args[1].vval.v_string = base != NULL ? base : (char_u *)"";
args[2].v_type = VAR_UNKNOWN;
pos = curwin->w_cursor;
curwin_save = curwin;
curbuf_save = curbuf;
/* Call a function, which returns a list or dict. */
if (call_vim_function(funcname, 2, args, FALSE, FALSE, &rettv) == OK)
if (call_vim_function(funcname, 2, args, &rettv, FALSE) == OK)
{
switch (rettv.v_type)
{
@@ -5528,7 +5531,7 @@ ins_complete(int c, int enable_pum)
* Call user defined function 'completefunc' with "a:findstart"
* set to 1 to obtain the length of text to use for completion.
*/
char_u *args[2];
typval_T args[3];
int col;
char_u *funcname;
pos_T pos;
@@ -5548,8 +5551,11 @@ ins_complete(int c, int enable_pum)
return FAIL;
}
args[0] = (char_u *)"1";
args[1] = NULL;
args[0].v_type = VAR_NUMBER;
args[0].vval.v_number = 1;
args[1].v_type = VAR_STRING;
args[1].vval.v_string = (char_u *)"";
args[2].v_type = VAR_UNKNOWN;
pos = curwin->w_cursor;
curwin_save = curwin;
curbuf_save = curbuf;