aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-10-28 16:09:39 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-10-29 08:20:00 +0800
commit6b8c3d146ec0308fd19a9142b23b5e342e2cdcf8 (patch)
tree3aa44f8e29de049e84c9db98acb11fe195e5deba /test
parent378d9135e7ac0f91a4944be816dc9f693d5078af (diff)
downloadrneovim-6b8c3d146ec0308fd19a9142b23b5e342e2cdcf8.tar.gz
rneovim-6b8c3d146ec0308fd19a9142b23b5e342e2cdcf8.tar.bz2
rneovim-6b8c3d146ec0308fd19a9142b23b5e342e2cdcf8.zip
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 <yegappan@yahoo.com>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_findfile.vim36
1 files changed, 33 insertions, 3 deletions
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 \<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindexpr1.c', @:)
+
+ call feedkeys(":find Xfind\<Tab>\<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindexpr2.c', @:)
+
+ call feedkeys(":find *3*\<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindexpr3.c', @:)
+
+ call feedkeys(":find Xfind\<C-A>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindexpr1.c Xfindexpr2.c Xfindexpr3.c', @:)
+
+ call feedkeys(":find abc\<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find abc', @:)
+
+ set findexpr&
+ delfunc! FindExpr1
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab