From 12e015175043078451fde1544df4fd525bd85e25 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 5 Aug 2018 23:45:50 -0400 Subject: [PATCH] Adjust completion of /absolute/paths Support for an initial slash to access a work tree file is being phased out. --- autoload/fugitive.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 462df43..f8d593c 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -973,8 +973,8 @@ endfunction function! fugitive#PathComplete(base, ...) abort let dir = a:0 == 1 ? a:1 : get(b:, 'git_dir', '') let tree = FugitiveTreeForGitDir(dir) . '/' - let strip = '^\%(:\=/\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)\%(\./\)\=' - let base = substitute(a:base, strip, '', '') + let strip = '^\%(:/\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)\%(\./\)\=' + let base = substitute((a:base =~# '^/' ? '.' : '') . a:base, strip, '', '') if base =~# '^\.git/' let pattern = s:gsub(base[5:-1], '/', '*&').'*' let matches = s:GlobComplete(dir . '/', pattern) @@ -984,11 +984,16 @@ function! fugitive#PathComplete(base, ...) abort endif call s:Uniq(matches) call map(matches, "'.git/' . v:val") + elseif base =~# '^\~/' + let matches = map(s:GlobComplete(expand('~/'), base[2:-1] . '*'), '"~/" . v:val') elseif len(tree) > 1 let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*') else let matches = [] endif + if empty(matches) && a:base =~# '^/\|^\a\+:' + let matches = s:GlobComplete('', a:base . '*') + endif call map(matches, 's:fnameescape(s:Slash(matchstr(a:base, strip) . v:val))') return matches endfunction