mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
Accept multiple arguments to :Gdrop, like :drop
This commit is contained in:
@@ -5978,7 +5978,7 @@ function! s:PlusEscape(string) abort
|
|||||||
return substitute(a:string, '\\*[|" ]', '\=repeat("\\", len(submatch(0))).submatch(0)', 'g')
|
return substitute(a:string, '\\*[|" ]', '\=repeat("\\", len(submatch(0))).submatch(0)', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:OpenParse(string, wants_cmd) abort
|
function! s:OpenParse(string, wants_cmd, wants_multiple) abort
|
||||||
let opts = []
|
let opts = []
|
||||||
let cmds = []
|
let cmds = []
|
||||||
let args = s:ArgSplit(a:string)
|
let args = s:ArgSplit(a:string)
|
||||||
@@ -5994,14 +5994,20 @@ function! s:OpenParse(string, wants_cmd) abort
|
|||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
if empty(args)
|
if !a:wants_multiple && empty(args)
|
||||||
let args = ['>:']
|
let args = ['>:']
|
||||||
endif
|
endif
|
||||||
let dir = s:Dir()
|
let dir = s:Dir()
|
||||||
let [url, lnum] = s:OpenExpand(dir, join(args), a:wants_cmd)
|
let wants_cmd = a:wants_cmd
|
||||||
if lnum
|
let urls = []
|
||||||
call insert(cmds, lnum)
|
for arg in args
|
||||||
endif
|
let [url, lnum] = s:OpenExpand(dir, arg, wants_cmd)
|
||||||
|
if lnum
|
||||||
|
call insert(cmds, lnum)
|
||||||
|
endif
|
||||||
|
call add(urls, url)
|
||||||
|
let wants_cmd = 0
|
||||||
|
endfor
|
||||||
|
|
||||||
let pre = join(opts, '')
|
let pre = join(opts, '')
|
||||||
if len(cmds) > 1
|
if len(cmds) > 1
|
||||||
@@ -6009,7 +6015,7 @@ function! s:OpenParse(string, wants_cmd) abort
|
|||||||
elseif len(cmds)
|
elseif len(cmds)
|
||||||
let pre .= ' +' . s:PlusEscape(cmds[0])
|
let pre .= ' +' . s:PlusEscape(cmds[0])
|
||||||
endif
|
endif
|
||||||
return [url, pre]
|
return [a:wants_multiple ? urls : urls[0], pre]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:OpenExpand(dir, file, wants_cmd) abort
|
function! s:OpenExpand(dir, file, wants_cmd) abort
|
||||||
@@ -6099,17 +6105,33 @@ function! fugitive#Open(cmd, bang, mods, arg, ...) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let mods = s:Mods(a:mods)
|
let mods = s:Mods(a:mods)
|
||||||
if a:cmd ==# 'edit' || a:cmd ==# 'drop'
|
if a:cmd ==# 'edit'
|
||||||
call s:BlurStatus()
|
call s:BlurStatus()
|
||||||
endif
|
endif
|
||||||
try
|
try
|
||||||
let [file, pre] = s:OpenParse(a:arg, 1)
|
let [file, pre] = s:OpenParse(a:arg, 1, 0)
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr ' . string(v:exception)
|
return 'echoerr ' . string(v:exception)
|
||||||
endtry
|
endtry
|
||||||
return mods . a:cmd . pre . ' ' . s:fnameescape(file)
|
return mods . a:cmd . pre . ' ' . s:fnameescape(file)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! fugitive#DropCommand(line1, count, range, bang, mods, arg, ...) abort
|
||||||
|
exe s:VersionCheck()
|
||||||
|
|
||||||
|
let mods = s:Mods(a:mods)
|
||||||
|
try
|
||||||
|
let [files, pre] = s:OpenParse(a:arg, 1, 1)
|
||||||
|
catch /^fugitive:/
|
||||||
|
return 'echoerr ' . string(v:exception)
|
||||||
|
endtry
|
||||||
|
if empty(files)
|
||||||
|
return 'drop'
|
||||||
|
endif
|
||||||
|
call s:BlurStatus()
|
||||||
|
return mods . 'drop' . ' ' . s:fnameescape(files) . substitute(pre, '^ *+', '|', '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:ReadPrepare(line1, count, range, mods) abort
|
function! s:ReadPrepare(line1, count, range, mods) abort
|
||||||
let mods = s:Mods(a:mods)
|
let mods = s:Mods(a:mods)
|
||||||
let after = a:count
|
let after = a:count
|
||||||
@@ -6133,7 +6155,7 @@ function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, ...) abort
|
|||||||
exe s:VersionCheck()
|
exe s:VersionCheck()
|
||||||
let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods)
|
let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods)
|
||||||
try
|
try
|
||||||
let [file, pre] = s:OpenParse(a:arg, 0)
|
let [file, pre] = s:OpenParse(a:arg, 0, 0)
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr ' . string(v:exception)
|
return 'echoerr ' . string(v:exception)
|
||||||
endtry
|
endtry
|
||||||
|
|||||||
@@ -577,7 +577,7 @@ exe 'command! -bar -bang -nargs=* -complete=customlist,
|
|||||||
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>)'
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>)'
|
||||||
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>)'
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>)'
|
||||||
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#EditComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>)'
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#EditComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>)'
|
||||||
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdrop exe fugitive#Open("drop", <bang>0, "<mods>", <q-args>)'
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdrop exe fugitive#DropCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
||||||
|
|
||||||
if exists(':Gr') != 2
|
if exists(':Gr') != 2
|
||||||
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
||||||
|
|||||||
Reference in New Issue
Block a user