vim-patch:8.2.0407: no early check if :find and :sfind have an argument

Problem:    No early check if :find and :sfind have an argument.
Solution:   Add EX_NEEDARG.
2d10cd4780

Cherry-pick Test_find_cmd() from patch v8.2.0270.
Use "exe 'cd ' . save_dir" pattern
because patches v8.1.1291, v8.1.2278 are not ported yet.
Cherry-pick modeline from patch v8.1.1432.
This commit is contained in:
Jan Edmund Lazo
2021-01-02 02:23:24 -05:00
parent ffc3df51f1
commit cb5ba225f8
3 changed files with 49 additions and 6 deletions

View File

@@ -971,7 +971,7 @@ module.cmds = {
}, },
{ {
command='find', command='find',
flags=bit.bor(RANGE, BANG, FILE1, CMDARG, ARGOPT, TRLBAR), flags=bit.bor(RANGE, BANG, FILE1, CMDARG, ARGOPT, TRLBAR, NEEDARG),
addr_type='ADDR_OTHER', addr_type='ADDR_OTHER',
func='ex_find', func='ex_find',
}, },
@@ -2425,7 +2425,7 @@ module.cmds = {
}, },
{ {
command='sfind', command='sfind',
flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR), flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR, NEEDARG),
addr_type='ADDR_OTHER', addr_type='ADDR_OTHER',
func='ex_splitview', func='ex_splitview',
}, },

View File

@@ -15,22 +15,22 @@ func Test_find_complete()
new new
set path= set path=
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E345:') call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close close
new new
set path=. set path=.
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E32:') call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close close
new new
set path=.,, set path=.,,
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E32:') call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close close
new new
set path=./** set path=./**
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E32:') call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close close
" We shouldn't find any file till this point " We shouldn't find any file till this point

View File

@@ -184,3 +184,46 @@ func Test_finddir_error()
call assert_fails('call finddir("x", "**x")', 'E343:') call assert_fails('call finddir("x", "**x")', 'E343:')
call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:') call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:')
endfunc endfunc
" Test for the :find, :sfind and :tabfind commands
func Test_find_cmd()
new
let save_path = &path
let save_dir = getcwd()
set path=.,./**/*
call CreateFiles()
cd Xdir1
" Test for :find
find foo
call assert_equal('foo', expand('%:.'))
2find foo
call assert_equal('Xdir2/foo', expand('%:.'))
call assert_fails('3find foo', 'E347:')
" Test for :sfind
enew
sfind barfoo
call assert_equal('Xdir2/Xdir3/barfoo', expand('%:.'))
call assert_equal(3, winnr('$'))
close
call assert_fails('sfind baz', 'E345:')
call assert_equal(2, winnr('$'))
" Test for :tabfind
enew
tabfind foobar
call assert_equal('Xdir2/foobar', expand('%:.'))
call assert_equal(2, tabpagenr('$'))
tabclose
call assert_fails('tabfind baz', 'E345:')
call assert_equal(1, tabpagenr('$'))
" call chdir(save_dir)
exe 'cd ' . save_dir
call CleanFiles()
let &path = save_path
close
call assert_fails('find', 'E471:')
call assert_fails('sfind', 'E471:')
call assert_fails('tabfind', 'E471:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab