From e2918e51968a9497ca851cfffba58001e50de7f6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 2 Jun 2020 19:24:44 -0400 Subject: [PATCH] Validate 'do' option --- plug.vim | 5 +++++ test/workflow.vader | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index 0603ebe..8332537 100644 --- a/plug.vim +++ b/plug.vim @@ -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 diff --git a/test/workflow.vader b/test/workflow.vader index 58e59b7..355928a 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -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)