Skip to content

Commit baa66bc

Browse files
authored
Allow command modifiers for on-demand-loading commands (#1110)
Before this commit, commands like this - :tab Git diff HEAD^ HEAD were interpreted like this - :Git diff HEAD^ HEAD This commit fixes that issue.
1 parent cdea024 commit baa66bc

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

plug.vim

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ function! plug#end()
372372

373373
for [cmd, names] in items(lod.cmd)
374374
execute printf(
375-
\ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
376-
\ cmd, string(cmd), string(names))
375+
\ has('patch-7.4.1898')
376+
\ ? 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, <q-mods> ,%s)'
377+
\ : 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)'
378+
\ , cmd, string(cmd), string(names))
377379
endfor
378380

379381
for [map, names] in items(lod.map)
@@ -651,11 +653,19 @@ function! s:lod_ft(pat, names)
651653
call s:doautocmd('filetypeindent', 'FileType')
652654
endfunction
653655

654-
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
655-
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
656-
call s:dobufread(a:names)
657-
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
658-
endfunction
656+
if has('patch-7.4.1898')
657+
function! s:lod_cmd(cmd, bang, l1, l2, args, mods, names)
658+
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
659+
call s:dobufread(a:names)
660+
execute printf('%s %s%s%s %s', a:mods, (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
661+
endfunction
662+
else
663+
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
664+
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
665+
call s:dobufread(a:names)
666+
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
667+
endfunction
668+
endif
659669

660670
function! s:lod_map(map, names, with_prefix, prefix)
661671
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])

0 commit comments

Comments
 (0)