Make :Gcd global

This commit is contained in:
Tim Pope
2019-09-03 21:27:13 -04:00
parent 77a732c97c
commit 2464b0c29a
2 changed files with 10 additions and 9 deletions

View File

@@ -2175,22 +2175,20 @@ endfunction
" Section: :Gcd, :Glcd
function! s:DirComplete(A, L, P) abort
function! fugitive#CdComplete(A, L, P) abort
return filter(fugitive#CompletePath(a:A), 'v:val =~# "/$"')
endfunction
function! s:DirArg(path) abort
function! fugitive#Cd(path, ...) abort
let path = substitute(a:path, '^:/:\=\|^:(\%(top\|top,literal\|literal,top\|literal\))', '', '')
if path =~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)'
return path
else
return FugitiveVimPath((empty(s:Tree()) ? s:Dir() : s:Tree()) . '/' . path)
if path !~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)'
let dir = s:Dir()
exe s:DirCheck(dir)
let path = (empty(s:Tree(dir)) ? dir : s:Tree(dir)) . '/' . path
endif
return (a:0 && a:1 ? 'lcd ' : 'cd ') . s:fnameescape(FugitiveVimPath(path))
endfunction
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Gcd :exe s:DirCheck()|exe 'cd<bang>' s:fnameescape(s:DirArg(<q-args>))")
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe s:DirCheck()|exe 'lcd<bang>' s:fnameescape(s:DirArg(<q-args>))")
" Section: :Gstatus
call s:command("-bar -bang -range=-1 -addr=other Gstatus", "Status")