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>
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 80ccce8..027cf08 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt*	For Vim version 9.1.  Last change: 2024 Oct 22
+*eval.txt*	For Vim version 9.1.  Last change: 2024 Oct 28
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -2026,6 +2026,11 @@
 		was used the value is 1, otherwise it is 0.  Note that this
 		can only be used in autocommands.  For user commands |<bang>|
 		can be used.
+
+					*v:cmdcomplete* *cmdcomplete-variable*
+v:cmdcomplete	When evaluating 'findexpr': if 'findexpr' is used for cmdline
+		completion the value is |v:true|, otherwise it is |v:false|.
+
 						*v:collate* *collate-variable*
 v:collate	The current locale setting for collation order of the runtime
 		environment.  This allows Vim scripts to be aware of the
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 229ce13..e221fe3 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*	For Vim version 9.1.  Last change: 2024 Oct 22
+*options.txt*	For Vim version 9.1.  Last change: 2024 Oct 28
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -3567,6 +3567,10 @@
 	The expression is evaluated only once per |:find| command invocation.
 	The expression can process all the directories specified in 'path'.
 
+	The expression may be evaluated for command-line completion as well,
+	in which case the |v:cmdcomplete| variable will be set to |v:true|,
+	otherwise it will be set to |v:false|.
+
 	If a match is found, the expression should return a |List| containing
 	one or more file names.  If a match is not found, the expression
 	should return an empty List.
@@ -3586,7 +3590,8 @@
 >
 	    " Use glob()
 	    func FindExprGlob()
-		return glob(v:fname, v:false, v:true)
+		let pat = v:cmdcomplete ? $'{v:fname}*' : v:fname
+		return glob(pat, v:false, v:true)
 	    endfunc
 	    set findexpr=FindExprGlob()
 
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 9e93a75..886b28c 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6510,6 +6510,7 @@
 closure	eval.txt	/*closure*
 cmdarg-variable	eval.txt	/*cmdarg-variable*
 cmdbang-variable	eval.txt	/*cmdbang-variable*
+cmdcomplete-variable	eval.txt	/*cmdcomplete-variable*
 cmdline-arguments	vi_diff.txt	/*cmdline-arguments*
 cmdline-changed	version5.txt	/*cmdline-changed*
 cmdline-completion	cmdline.txt	/*cmdline-completion*
@@ -10933,6 +10934,7 @@
 v:charconvert_to	eval.txt	/*v:charconvert_to*
 v:cmdarg	eval.txt	/*v:cmdarg*
 v:cmdbang	eval.txt	/*v:cmdbang*
+v:cmdcomplete	eval.txt	/*v:cmdcomplete*
 v:collate	eval.txt	/*v:collate*
 v:colornames	eval.txt	/*v:colornames*
 v:completed_item	eval.txt	/*v:completed_item*