patch 9.1.0821: 'findexpr' completion doesn't set v:fname to cmdline argument

Problem:  'findexpr' completion doesn't set v:fname to cmdline argument.
Solution: Set v:fname to the cmdline argument as-is (zeertzjq).

closes: #15934

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-10-28 22:05:26 +01:00
committed by Christian Brabandt
parent baab7c0865
commit 20e045f781
10 changed files with 75 additions and 38 deletions

View File

@ -6929,7 +6929,7 @@ ex_wrongmodifier(exarg_T *eap)
* the expression, v:fname is set to the ":find" command argument.
*/
static list_T *
eval_findexpr(char_u *ptr)
eval_findexpr(char_u *pat, int cmdcomplete)
{
sctx_T saved_sctx = current_sctx;
char_u *findexpr;
@ -6939,7 +6939,8 @@ eval_findexpr(char_u *ptr)
findexpr = get_findexpr();
set_vim_var_string(VV_FNAME, ptr, -1);
set_vim_var_string(VV_FNAME, pat, -1);
set_vim_var_nr(VV_CMDCOMPLETE, cmdcomplete ? VVAL_TRUE : VVAL_FALSE);
current_sctx = curbuf->b_p_script_ctx[BV_FEXPR];
arg = skipwhite(findexpr);
@ -6962,6 +6963,7 @@ eval_findexpr(char_u *ptr)
clear_evalarg(&EVALARG_EVALUATE, NULL);
set_vim_var_string(VV_FNAME, NULL, 0);
set_vim_var_nr(VV_CMDCOMPLETE, VVAL_FALSE);
current_sctx = saved_sctx;
return retlist;
@ -6977,21 +6979,11 @@ expand_findexpr(char_u *pat, char_u ***files, int *numMatches)
{
list_T *l;
int len;
char_u *regpat;
*numMatches = 0;
*files = NULL;
// File name expansion uses wildchars. But the 'findexpr' expression
// expects a regular expression argument. So convert wildchars in the
// argument to regular expression patterns.
regpat = file_pat_to_reg_pat(pat, NULL, NULL, FALSE);
if (regpat == NULL)
return FAIL;
l = eval_findexpr(regpat);
vim_free(regpat);
l = eval_findexpr(pat, TRUE);
if (l == NULL)
return FAIL;
@ -7037,7 +7029,7 @@ findexpr_find_file(char_u *findarg, int findarg_len, int count)
cc = findarg[findarg_len];
findarg[findarg_len] = NUL;
fname_list = eval_findexpr(findarg);
fname_list = eval_findexpr(findarg, FALSE);
fname_count = list_len(fname_list);
if (fname_count == 0)