diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index e17fe74..2e9a7f0 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1092,7 +1092,7 @@ function! s:Edit(cmd,bang,...) abort endif if a:bang - let args = s:gsub(a:0 ? a:1 : '', '\\@' @@ -1148,7 +1148,7 @@ function! s:Edit(cmd,bang,...) abort endfunction function! s:EditComplete(A,L,P) abort - return s:repo().superglob(a:A) + return map(s:repo().superglob(a:A), 'fnameescape(v:val)') endfunction function! s:EditRunComplete(A,L,P) abort @@ -1159,20 +1159,20 @@ function! s:EditRunComplete(A,L,P) abort endif endfunction -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Ge :execute s:Edit('edit',0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gedit :execute s:Edit('edit',0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditRunComplete Gpedit :execute s:Edit('pedit',0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditRunComplete Gsplit :execute s:Edit('split',0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditRunComplete Gvsplit :execute s:Edit('vsplit',0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditRunComplete Gtabedit :execute s:Edit('tabedit',0,)") -call s:command("-bar -bang -nargs=? -count -complete=customlist,s:EditRunComplete Gread :execute s:Edit((! && ? '' : ).'read',0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Ge :execute s:Edit('edit',0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gedit :execute s:Edit('edit',0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gpedit :execute s:Edit('pedit',0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gsplit :execute s:Edit('split',0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gvsplit :execute s:Edit('vsplit',0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gtabedit :execute s:Edit('tabedit',0,)") +call s:command("-bar -bang -nargs=* -count -complete=customlist,s:EditRunComplete Gread :execute s:Edit((! && ? '' : ).'read',0,)") " }}}1 " Gwrite, Gwq {{{1 -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwrite :execute s:Write(0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gw :execute s:Write(0,)") -call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwq :execute s:Wq(0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gwrite :execute s:Write(0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gw :execute s:Write(0,)") +call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gwq :execute s:Wq(0,)") function! s:Write(force,...) abort if exists('b:fugitive_commit_arguments') @@ -1202,7 +1202,7 @@ function! s:Write(force,...) abort endif let mytab = tabpagenr() let mybufnr = bufnr('') - let path = a:0 ? a:1 : s:buffer().path() + let path = a:0 ? join(a:000, ' ') : s:buffer().path() if path =~# '^:\d\>' return 'write'.(a:force ? '! ' : ' ').s:fnameescape(s:repo().translate(s:buffer().expand(path))) endif @@ -1327,9 +1327,9 @@ endfunction " }}}1 " Gdiff {{{1 -call s:command("-bang -bar -nargs=? -complete=customlist,s:EditComplete Gdiff :execute s:Diff(0,)") -call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gvdiff :execute s:Diff(0,)") -call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gsdiff :execute s:Diff(1,)") +call s:command("-bang -bar -nargs=* -complete=customlist,s:EditComplete Gdiff :execute s:Diff(0,)") +call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gvdiff :execute s:Diff(0,)") +call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execute s:Diff(1,)") augroup fugitive_diff autocmd! @@ -1421,20 +1421,21 @@ function! s:Diff(bang,...) call s:diffthis() return '' elseif a:0 - if a:1 ==# '' + let arg = join(a:000, ' ') + if arg ==# '' return '' - elseif a:1 ==# '/' + elseif arg ==# '/' let file = s:buffer().path('/') - elseif a:1 ==# ':' + elseif arg ==# ':' let file = s:buffer().path(':0:') - elseif a:1 =~# '^:/.' + elseif arg =~# '^:/.' try - let file = s:repo().rev_parse(a:1).s:buffer().path(':') + let file = s:repo().rev_parse(arg).s:buffer().path(':') catch /^fugitive:/ return 'echoerr v:errmsg' endtry else - let file = s:buffer().expand(a:1) + let file = s:buffer().expand(arg) endif if file !~# ':' && file !~# '^/' && s:repo().git_chomp('cat-file','-t',file) =~# '^\%(tag\|commit\)$' let file = file.s:buffer().path(':') @@ -1761,11 +1762,11 @@ endfunction " }}}1 " Gbrowse {{{1 -call s:command("-bar -bang -range -nargs=? -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(0,,,)") +call s:command("-bar -bang -range -nargs=* -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(0,,,)") function! s:Browse(bang,line1,count,...) abort try - let rev = a:0 ? substitute(a:1,'@[[:alnum:]_-]*\%(://.\{-\}\)\=$','','') : '' + let rev = a:0 ? substitute(join(a:000, ' '),'@[[:alnum:]_-]*\%(://.\{-\}\)\=$','','') : '' if rev ==# '' let expanded = s:buffer().rev() elseif rev ==# ':' @@ -1808,8 +1809,8 @@ function! s:Browse(bang,line1,count,...) abort endif endif - if a:0 && a:1 =~# '@[[:alnum:]_-]*\%(://.\{-\}\)\=$' - let remote = matchstr(a:1,'@\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$') + if a:0 && join(a:000, ' ') =~# '@[[:alnum:]_-]*\%(://.\{-\}\)\=$' + let remote = matchstr(join(a:000, ' '),'@\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$') elseif path =~# '^\.git/refs/remotes/.' let remote = matchstr(path,'^\.git/refs/remotes/\zs[^/]\+') else