Use forward slashes for non-Fugitive URLs on win32

Might do this for everything but let's start here.  I initially went
with backslashes for URLs because that's how Vim on win32 normalizes
buffer names, and figured it might simplify things like equality checks.
But Vim itself breaks in some places.  Editing a `file://` URL doesn't
work if backslashes are in use, and Vim unescapes incorrectly when
constructing <q-args> (see 6356bbc4a7).
This commit is contained in:
Tim Pope
2022-06-27 00:54:54 -04:00
parent ecc5e8fa40
commit 09dfed092a

View File

@@ -1770,7 +1770,9 @@ function! fugitive#Find(object, ...) abort
return s:VimSlash(FugitiveVimPath((len(owner) ? owner : prefix) . strpart(a:object, len(prefix))))
endif
let rev = s:Slash(a:object)
if rev =~# '^$\|^/\|^\%(\a\a\+:\).*\%(//\|::\)' . (has('win32') ? '\|^\a:/' : '')
if rev =~# '^\a\+://' && rev !~# '^fugitive:'
return rev
elseif rev =~# '^$\|^/\|^\%(\a\a\+:\).*\%(//\|::\)' . (has('win32') ? '\|^\a:/' : '')
return s:VimSlash(a:object)
elseif rev =~# '^\.\.\=\%(/\|$\)'
return s:VimSlash(simplify(getcwd() . '/' . a:object))
@@ -6024,7 +6026,7 @@ function! s:OpenExpand(dir, file, wants_cmd) abort
let url = s:Generate(efile, a:dir)
if a:wants_cmd && a:file[0] ==# '>' && efile[0] !=# '>' && get(b:, 'fugitive_type', '') isnot# 'tree' && &filetype !=# 'netrw'
let line = line('.')
if expand('%:p') !=# url
if s:Slash(expand('%:p')) !=# s:Slash(url)
let diffcmd = 'diff'
let from = s:DirRev(@%)[1]
let to = s:DirRev(url)[1]