From 6b8c3d146ec0308fd19a9142b23b5e342e2cdcf8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 28 Oct 2024 16:09:39 +0800 Subject: vim-patch:9.1.0811: :find expansion does not consider 'findexpr' Problem: :find expansion does not consider 'findexpr' Solution: Support expanding :find command argument using 'findexpr' (Yegappan Lakshmanan) closes: vim/vim#15929 https://github.com/vim/vim/commit/2f6efaccfd5c4e7df1f54ed0f41f329abbe05f60 Co-authored-by: Yegappan Lakshmanan --- test/old/testdir/test_findfile.vim | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/old/testdir/test_findfile.vim b/test/old/testdir/test_findfile.vim index baf33898fe..8e25975b53 100644 --- a/test/old/testdir/test_findfile.vim +++ b/test/old/testdir/test_findfile.vim @@ -299,7 +299,6 @@ func Test_findexpr() " basic tests func FindExpr1() let fnames = ['Xfindexpr1.c', 'Xfindexpr2.c', 'Xfindexpr3.c'] - "return fnames->copy()->filter('v:val =~? v:fname')->join("\n") return fnames->copy()->filter('v:val =~? v:fname') endfunc @@ -358,8 +357,8 @@ func Test_findexpr() set findexpr=FindExpr2() call assert_fails('find Xfindexpr1.c', 'find error') - " Try using a null string as the expression - set findexpr=v:_null_string + " Try using a null List as the expression + set findexpr=v:_null_list call assert_fails('find Xfindexpr1.c', 'E345: Can''t find file "Xfindexpr1.c" in path') " Try to create a new window from the find expression @@ -378,6 +377,10 @@ func Test_findexpr() set findexpr=FindExpr4() call assert_fails('find Xfindexpr1.c', 'E565: Not allowed to change text or change window') + " Expression returning a string + set findexpr='abc' + call assert_fails('find Xfindexpr1.c', 'E1514: findexpr did not return a List type') + set findexpr& delfunc! FindExpr1 delfunc! FindExpr2 @@ -454,4 +457,31 @@ func Test_findexpr_scriptlocal_func() delfunc s:FindExprScript endfunc +" Test for expanding the argument to the :find command using 'findexpr' +func Test_findexpr_expand_arg() + func FindExpr1() + let fnames = ['Xfindexpr1.c', 'Xfindexpr2.c', 'Xfindexpr3.c'] + return fnames->copy()->filter('v:val =~? v:fname') + endfunc + set findexpr=FindExpr1() + + call feedkeys(":find \\\"\", "xt") + call assert_equal('"find Xfindexpr1.c', @:) + + call feedkeys(":find Xfind\\\\"\", "xt") + call assert_equal('"find Xfindexpr2.c', @:) + + call feedkeys(":find *3*\\\"\", "xt") + call assert_equal('"find Xfindexpr3.c', @:) + + call feedkeys(":find Xfind\\\"\", "xt") + call assert_equal('"find Xfindexpr1.c Xfindexpr2.c Xfindexpr3.c', @:) + + call feedkeys(":find abc\\\"\", "xt") + call assert_equal('"find abc', @:) + + set findexpr& + delfunc! FindExpr1 +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit