Validate 'do' option

This commit is contained in:
Jan Edmund Lazo 2020-06-02 19:24:44 -04:00
parent 4fc2faf697
commit e2918e5196
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 11 additions and 1 deletions

View File

@ -660,6 +660,11 @@ function! s:parse_options(arg)
throw printf(opt_errfmt, opt, 'string or list')
endif
endfor
if has_key(opts, 'do')
\ && type(opts.do) != s:TYPE.funcref
\ && (type(opts.do) != s:TYPE.string || empty(opts.do))
throw printf(opt_errfmt, 'do', 'string or funcref')
endif
if has_key(opts, 'dir')
let opts.dir = s:dirpath(s:plug_expand(opts.dir))
endif

View File

@ -97,6 +97,10 @@ Execute (Plug command with dictionary option):
redir END
Assert out =~ 'Invalid argument for "'.opt.'" option of :Plug (expected: string or list)'
endfor
redir => out
Plug 'foo/bar.vim', {'do': ''}
redir END
Assert out =~ 'Invalid argument for "do" option of :Plug (expected: string or funcref)'
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual '././', g:plugs['seoul256.vim'].rtp
@ -1057,9 +1061,10 @@ Execute (Post-update hook output; success and failure):
Execute (Post-update hook output; invalid type or funcref):
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'do': 1 }
Plug 'junegunn/vim-easy-align', { 'do': ':echo 1' }
Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
call plug#end()
let g:plugs['vim-easy-align'].do = 1
silent PlugInstall! 1
AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)