Skip to content

Commit 5c66e23

Browse files
glepnirchrisbra
authored andcommitted
patch 9.1.0867: ins_compl_add() has too many args
Problem: ins_compl_add() has too many args Solution: refactor it and use an int array instead of 2 separate int args (glepnir) closes: #16062 Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 54996ec commit 5c66e23

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/insexpand.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static int compl_selected_item = -1;
198198

199199
static int *compl_fuzzy_scores;
200200

201-
static int ins_compl_add(char_u *str, int len, char_u *fname, char_u **cptext, typval_T *user_data, int cdir, int flags, int adup, int user_hlattr, int user_kind_hlattr);
201+
static int ins_compl_add(char_u *str, int len, char_u *fname, char_u **cptext, typval_T *user_data, int cdir, int flags, int adup, int *extra_hl);
202202
static void ins_compl_longest_match(compl_T *match);
203203
static void ins_compl_del_pum(void);
204204
static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, regmatch_T *regmatch, char_u *buf, int *dir);
@@ -738,7 +738,7 @@ ins_compl_add_infercase(
738738
if (icase)
739739
flags |= CP_ICASE;
740740

741-
res = ins_compl_add(str, len, fname, NULL, NULL, dir, flags, FALSE, -1, -1);
741+
res = ins_compl_add(str, len, fname, NULL, NULL, dir, flags, FALSE, NULL);
742742
vim_free(tofree);
743743
return res;
744744
}
@@ -755,6 +755,7 @@ ins_compl_add_infercase(
755755
* cdir - match direction. If 0, use "compl_direction".
756756
* flags_arg - match flags (cp_flags)
757757
* adup - accept this match even if it is already present.
758+
* *extra_hl - list of extra highlight attributes for abbr kind.
758759
* If "cdir" is FORWARD, then the match is added after the current match.
759760
* Otherwise, it is added before the current match.
760761
*
@@ -772,8 +773,7 @@ ins_compl_add(
772773
int cdir,
773774
int flags_arg,
774775
int adup, // accept duplicate match
775-
int user_abbr_hlattr,
776-
int user_kind_hlattr)
776+
int *extra_hl) // user abbr/kind hlattr
777777
{
778778
compl_T *match;
779779
int dir = (cdir == 0 ? compl_direction : cdir);
@@ -837,8 +837,8 @@ ins_compl_add(
837837
else
838838
match->cp_fname = NULL;
839839
match->cp_flags = flags;
840-
match->cp_user_abbr_hlattr = user_abbr_hlattr;
841-
match->cp_user_kind_hlattr = user_kind_hlattr;
840+
match->cp_user_abbr_hlattr = extra_hl ? extra_hl[0] : -1;
841+
match->cp_user_kind_hlattr = extra_hl ? extra_hl[1] : -1;
842842

843843
if (cptext != NULL)
844844
{
@@ -991,7 +991,7 @@ ins_compl_add_matches(
991991

992992
for (i = 0; i < num_matches && add_r != FAIL; i++)
993993
if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, NULL, dir,
994-
CP_FAST | (icase ? CP_ICASE : 0), FALSE, -1, -1)) == OK)
994+
CP_FAST | (icase ? CP_ICASE : 0), FALSE, NULL)) == OK)
995995
// if dir was BACKWARD then honor it just once
996996
dir = FORWARD;
997997
FreeWild(num_matches, matches);
@@ -2865,9 +2865,8 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
28652865
typval_T user_data;
28662866
int status;
28672867
char_u *user_abbr_hlname;
2868-
int user_abbr_hlattr = -1;
28692868
char_u *user_kind_hlname;
2870-
int user_kind_hlattr = -1;
2869+
int extra_hl[2] = { -1, -1 };
28712870

28722871
user_data.v_type = VAR_UNKNOWN;
28732872
if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
@@ -2879,10 +2878,10 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
28792878
cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict, "info", FALSE);
28802879

28812880
user_abbr_hlname = dict_get_string(tv->vval.v_dict, "abbr_hlgroup", FALSE);
2882-
user_abbr_hlattr = get_user_highlight_attr(user_abbr_hlname);
2881+
extra_hl[0] = get_user_highlight_attr(user_abbr_hlname);
28832882

28842883
user_kind_hlname = dict_get_string(tv->vval.v_dict, "kind_hlgroup", FALSE);
2885-
user_kind_hlattr = get_user_highlight_attr(user_kind_hlname);
2884+
extra_hl[1] = get_user_highlight_attr(user_kind_hlname);
28862885

28872886
dict_get_tv(tv->vval.v_dict, "user_data", &user_data);
28882887
if (dict_get_string(tv->vval.v_dict, "icase", FALSE) != NULL
@@ -2907,8 +2906,7 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
29072906
return FAIL;
29082907
}
29092908
status = ins_compl_add(word, -1, NULL, cptext,
2910-
&user_data, dir, flags, dup,
2911-
user_abbr_hlattr, user_kind_hlattr);
2909+
&user_data, dir, flags, dup, extra_hl);
29122910
if (status != OK)
29132911
clear_tv(&user_data);
29142912
return status;
@@ -2995,7 +2993,7 @@ set_completion(colnr_T startcol, list_T *list)
29952993
flags |= CP_ICASE;
29962994
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
29972995
-1, NULL, NULL, NULL, 0,
2998-
flags | CP_FAST, FALSE, -1, -1) != OK)
2996+
flags | CP_FAST, FALSE, NULL) != OK)
29992997
return;
30002998

30012999
ctrl_x_mode = CTRL_X_EVAL;
@@ -5234,7 +5232,7 @@ ins_compl_start(void)
52345232
if (p_ic)
52355233
flags |= CP_ICASE;
52365234
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
5237-
-1, NULL, NULL, NULL, 0, flags, FALSE, -1, -1) != OK)
5235+
-1, NULL, NULL, NULL, 0, flags, FALSE, NULL) != OK)
52385236
{
52395237
VIM_CLEAR(compl_pattern);
52405238
compl_patternlen = 0;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
867,
707709
/**/
708710
866,
709711
/**/

0 commit comments

Comments
 (0)