diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-06-12 22:05:14 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-06-12 22:05:14 +0200 |
commit | ffa9684150f5441e84d492e7184ef73587bd6c6c (patch) | |
tree | e73aa4b5e0d37ef4d113fcb07f9e1efa5c01d133 /src/edit.c | |
parent | 83f4cbd973731872b633d6ba0caf850fb708d70c (diff) |
patch 8.1.0053: first argument of 'completefunc' has inconsistent typev8.1.0053
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)
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/edit.c b/src/edit.c index 731b9dc7ff..92c9d6ad44 100644 --- a/src/edit.c +++ b/src/edit.c @@ -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; |