diff options
author | glepnir <glephunter@gmail.com> | 2024-11-28 13:54:59 +0800 |
---|---|---|
committer | glepnir <glephunter@gmail.com> | 2024-11-28 13:58:42 +0800 |
commit | 344923fe9a4d4966a8faf48d2767bfed181925c5 (patch) | |
tree | aab03ffb95949a1aa23a3a5aa96b71b80af038c3 /src/nvim/insexpand.c | |
parent | 66bb1e577c96d8eb63c04dcc737394b4ce2b0f5d (diff) | |
download | rneovim-344923fe9a4d4966a8faf48d2767bfed181925c5.tar.gz rneovim-344923fe9a4d4966a8faf48d2767bfed181925c5.tar.bz2 rneovim-344923fe9a4d4966a8faf48d2767bfed181925c5.zip |
vim-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: vim/vim#16062
https://github.com/vim/vim/commit/5c66e23c624717216d380d938d0bba5d34a004fe
Co-authored-by: glepnir <glephunter@gmail.com>
Diffstat (limited to 'src/nvim/insexpand.c')
-rw-r--r-- | src/nvim/insexpand.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index d3517667fb..154a142c74 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -758,7 +758,7 @@ int ins_compl_add_infercase(char *str_arg, int len, bool icase, char *fname, Dir flags |= CP_ICASE; } - int res = ins_compl_add(str, len, fname, NULL, false, NULL, dir, flags, false, -1, -1); + int res = ins_compl_add(str, len, fname, NULL, false, NULL, dir, flags, false, NULL); xfree(tofree); return res; } @@ -798,7 +798,7 @@ static inline void free_cptext(char *const *const cptext) /// returned in case of error. static int ins_compl_add(char *const str, int len, char *const fname, char *const *const cptext, const bool cptext_allocated, typval_T *user_data, const Direction cdir, - int flags_arg, const bool adup, int user_abbr_hlattr, int user_kind_hlattr) + int flags_arg, const bool adup, int *extra_hl) FUNC_ATTR_NONNULL_ARG(1) { compl_T *match; @@ -864,8 +864,8 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons match->cp_fname = NULL; } match->cp_flags = flags; - match->cp_user_abbr_hlattr = user_abbr_hlattr; - match->cp_user_kind_hlattr = user_kind_hlattr; + match->cp_user_abbr_hlattr = extra_hl ? extra_hl[0] : -1; + match->cp_user_kind_hlattr = extra_hl ? extra_hl[1] : -1; if (cptext != NULL) { int i; @@ -999,7 +999,7 @@ static void ins_compl_add_matches(int num_matches, char **matches, int icase) for (int i = 0; i < num_matches && add_r != FAIL; i++) { if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, false, NULL, dir, CP_FAST | (icase ? CP_ICASE : 0), - false, -1, -1)) == OK) { + false, NULL)) == OK) { // If dir was BACKWARD then honor it just once. dir = FORWARD; } @@ -2573,9 +2573,8 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast) int flags = fast ? CP_FAST : 0; char *(cptext[CPT_COUNT]); char *user_abbr_hlname = NULL; - int user_abbr_hlattr = -1; char *user_kind_hlname = NULL; - int user_kind_hlattr = -1; + int extra_hl[2] = { -1, -1 }; typval_T user_data; user_data.v_type = VAR_UNKNOWN; @@ -2587,10 +2586,10 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast) cptext[CPT_INFO] = tv_dict_get_string(tv->vval.v_dict, "info", true); user_abbr_hlname = tv_dict_get_string(tv->vval.v_dict, "abbr_hlgroup", false); - user_abbr_hlattr = get_user_highlight_attr(user_abbr_hlname); + extra_hl[0] = get_user_highlight_attr(user_abbr_hlname); user_kind_hlname = tv_dict_get_string(tv->vval.v_dict, "kind_hlgroup", false); - user_kind_hlattr = get_user_highlight_attr(user_kind_hlname); + extra_hl[1] = get_user_highlight_attr(user_kind_hlname); tv_dict_get_tv(tv->vval.v_dict, "user_data", &user_data); @@ -2613,8 +2612,7 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast) return FAIL; } int status = ins_compl_add((char *)word, -1, NULL, cptext, true, - &user_data, dir, flags, dup, - user_abbr_hlattr, user_kind_hlattr); + &user_data, dir, flags, dup, extra_hl); if (status != OK) { tv_clear(&user_data); } @@ -2707,7 +2705,7 @@ static void set_completion(colnr_T startcol, list_T *list) flags |= CP_ICASE; } if (ins_compl_add(compl_orig_text, -1, NULL, NULL, false, NULL, 0, - flags | CP_FAST, false, -1, -1) != OK) { + flags | CP_FAST, false, NULL) != OK) { return; } @@ -3452,7 +3450,7 @@ static void get_next_bufname_token(void) char *tail = path_tail(b->b_sfname); if (strncmp(tail, compl_orig_text, strlen(compl_orig_text)) == 0) { ins_compl_add(tail, (int)strlen(tail), NULL, NULL, false, NULL, 0, - p_ic ? CP_ICASE : 0, false, -1, -1); + p_ic ? CP_ICASE : 0, false, NULL); } } } @@ -4490,7 +4488,7 @@ static int ins_compl_start(void) flags |= CP_ICASE; } if (ins_compl_add(compl_orig_text, -1, NULL, NULL, false, NULL, 0, - flags, false, -1, -1) != OK) { + flags, false, NULL) != OK) { XFREE_CLEAR(compl_pattern); compl_patternlen = 0; XFREE_CLEAR(compl_orig_text); |