From 6356bbc4a761757b3ed2886d6808da5c1f4b2d75 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 12 Mar 2021 22:02:20 -0500 Subject: [PATCH] Fix argument parsing of :Gedit fugitive:\\... When expecting with -nargs=*, Vim rudely halves sequences of consecutive backslashes, mutilating our URLs on Windows in the process. Resort to splitting by hand instead. Closes https://github.com/tpope/vim-fugitive/issues/1579 --- autoload/fugitive.vim | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0466782..964878d 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -4463,10 +4463,22 @@ function! s:UsableWin(nr) abort \ index(['nofile','help','quickfix', 'terminal'], getbufvar(winbufnr(a:nr), '&buftype')) < 0 endfunction -function! s:OpenParse(args, wants_cmd) abort +function! s:ArgSplit(string) abort + let string = a:string + let args = [] + while string =~# '\S' + let arg = matchstr(string, '^\s*\%(\\.\|[^[:space:]]\)\+') + let string = strpart(string, len(arg)) + let arg = substitute(arg, '^\s\+', '', '') + call add(args, substitute(arg, '\\\@= 0 return 'echoerr ' . string('fugitive: ''-'' no longer required to get persistent URL if range given') else return 'echoerr ' . string('fugitive: use :0GBrowse instead of :GBrowse -') endif - elseif len(a:args) - let remote = matchstr(join(a:args, ' '),'@\zs\%('.validremote.'\)$') - let rev = substitute(join(a:args, ' '),'@\%('.validremote.'\)$','','') + elseif len(a:arg) + let remote = matchstr(a:arg, '@\zs\%('.validremote.'\)$') + let rev = substitute(a:arg, '@\%('.validremote.'\)$','','') else let remote = '' let rev = '' @@ -5770,7 +5782,7 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo if exec_error let commit = '' endif - if a:count > 0 && empty(a:args) && commit =~# '^\x\{40,\}$' + if a:count > 0 && empty(a:arg) && commit =~# '^\x\{40,\}$' let blame_list = tempname() call writefile([commit, ''], blame_list, 'b') let blame_in = tempname()