From 40e2dcba05635442d147394c2369c360c931bcfb Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 6 Aug 2018 01:21:19 -0400 Subject: [PATCH] Delegate to other real filename implementations --- autoload/fugitive.vim | 13 +++++++++---- plugin/fugitive.vim | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index bdc11ed..5e30096 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -488,16 +488,21 @@ function! s:DirRev(url) abort endfunction function! fugitive#Real(url) abort + if empty(a:url) + return '' + endif let [dir, commit, file] = s:DirCommitFile(a:url) if len(dir) let tree = s:Tree(dir) return s:PlatformSlash((len(tree) ? tree : dir) . file) endif - let url = len(a:url) ? fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) : '' - if url =~# '^[\\/]\|^\a:[\\/]' - return s:PlatformSlash(url) + let pre = substitute(matchstr(a:url, '^\a\a\+\ze:'), '^.', '\u&', '') + if len(pre) && pre !=? 'fugitive' && exists('*' . pre . 'Real') + let url = {pre}Real(a:url) + else + let url = fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) endif - return '' + return s:PlatformSlash(empty(url) ? a:url : url) endfunction function! fugitive#Path(url, ...) abort diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 1b18393..11b9fe1 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -34,9 +34,9 @@ endfunction function! FugitiveReal(...) abort let file = a:0 ? a:1 : @% - if file =~? '^fugitive:' || a:0 > 1 + if file =~# '^\a\a\+:' || a:0 > 1 return call('fugitive#Real', [file] + a:000[1:-1]) - elseif file =~# '^/\|^\a\+:\|^$' + elseif file =~# '^/\|^\a:\|^$' return file else return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??'))