diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 4e77e04..beb15ee 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -5978,7 +5978,7 @@ function! s:PlusEscape(string) abort return substitute(a:string, '\\*[|" ]', '\=repeat("\\", len(submatch(0))).submatch(0)', 'g') endfunction -function! s:OpenParse(string, wants_cmd) abort +function! s:OpenParse(string, wants_cmd, wants_multiple) abort let opts = [] let cmds = [] let args = s:ArgSplit(a:string) @@ -5994,14 +5994,20 @@ function! s:OpenParse(string, wants_cmd) abort break endif endwhile - if empty(args) + if !a:wants_multiple && empty(args) let args = ['>:'] endif let dir = s:Dir() - let [url, lnum] = s:OpenExpand(dir, join(args), a:wants_cmd) - if lnum - call insert(cmds, lnum) - endif + let wants_cmd = a:wants_cmd + let urls = [] + for arg in args + 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, '') if len(cmds) > 1 @@ -6009,7 +6015,7 @@ function! s:OpenParse(string, wants_cmd) abort elseif len(cmds) let pre .= ' +' . s:PlusEscape(cmds[0]) endif - return [url, pre] + return [a:wants_multiple ? urls : urls[0], pre] endfunction function! s:OpenExpand(dir, file, wants_cmd) abort @@ -6099,17 +6105,33 @@ function! fugitive#Open(cmd, bang, mods, arg, ...) abort endif let mods = s:Mods(a:mods) - if a:cmd ==# 'edit' || a:cmd ==# 'drop' + if a:cmd ==# 'edit' call s:BlurStatus() endif try - let [file, pre] = s:OpenParse(a:arg, 1) + let [file, pre] = s:OpenParse(a:arg, 1, 0) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry return mods . a:cmd . pre . ' ' . s:fnameescape(file) 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 let mods = s:Mods(a:mods) let after = a:count @@ -6133,7 +6155,7 @@ function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, ...) abort exe s:VersionCheck() let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods) try - let [file, pre] = s:OpenParse(a:arg, 0) + let [file, pre] = s:OpenParse(a:arg, 0, 0) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index aa373a6..c17d850 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -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(( > 0 ? : "").( ? "split" : "edit"), 0, "", )' exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gvsplit exe fugitive#Open(( > 0 ? : "").( ? "vsplit" : "edit!"), 0, "", )' exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#EditComplete Gtabedit exe fugitive#Open(( >= 0 ? : "")."tabedit", 0, "", )' -exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdrop exe fugitive#Open("drop", 0, "", )' +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdrop exe fugitive#DropCommand(, , +"", 0, "", )' if exists(':Gr') != 2 exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(, , +"", 0, "", )'