From 09dfed092a0c763737d9e5e631754757fb5ad909 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 27 Jun 2022 00:54:54 -0400 Subject: [PATCH] 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 (see 6356bbc4a761757b3ed2886d6808da5c1f4b2d75). --- autoload/fugitive.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 79b82b9..6fae37c 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -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]