diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 2bc7b14..47e883d 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -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' s:fnameescape(s:DirArg())") -call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe s:DirCheck()|exe 'lcd' s:fnameescape(s:DirArg())") - " Section: :Gstatus call s:command("-bar -bang -range=-1 -addr=other Gstatus", "Status") diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 2891e64..796c3cd 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -362,6 +362,9 @@ let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : '' exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete G exe fugitive#Command(, , +"", 0, "", )' exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete Git exe fugitive#Command(, , +"", 0, "", )' +exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(, 0)" +exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(, 1)" + exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Ge exe fugitive#Open("edit", 0, "", , [])' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gedit exe fugitive#Open("edit", 0, "", , [])' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", 0, "", , [])'