mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 06:13:51 -05:00
Adjust completion of /absolute/paths
Support for an initial slash to access a work tree file is being phased out.
This commit is contained in:
@@ -973,8 +973,8 @@ endfunction
|
|||||||
function! fugitive#PathComplete(base, ...) abort
|
function! fugitive#PathComplete(base, ...) abort
|
||||||
let dir = a:0 == 1 ? a:1 : get(b:, 'git_dir', '')
|
let dir = a:0 == 1 ? a:1 : get(b:, 'git_dir', '')
|
||||||
let tree = FugitiveTreeForGitDir(dir) . '/'
|
let tree = FugitiveTreeForGitDir(dir) . '/'
|
||||||
let strip = '^\%(:\=/\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)\%(\./\)\='
|
let strip = '^\%(:/\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)\%(\./\)\='
|
||||||
let base = substitute(a:base, strip, '', '')
|
let base = substitute((a:base =~# '^/' ? '.' : '') . a:base, strip, '', '')
|
||||||
if base =~# '^\.git/'
|
if base =~# '^\.git/'
|
||||||
let pattern = s:gsub(base[5:-1], '/', '*&').'*'
|
let pattern = s:gsub(base[5:-1], '/', '*&').'*'
|
||||||
let matches = s:GlobComplete(dir . '/', pattern)
|
let matches = s:GlobComplete(dir . '/', pattern)
|
||||||
@@ -984,11 +984,16 @@ function! fugitive#PathComplete(base, ...) abort
|
|||||||
endif
|
endif
|
||||||
call s:Uniq(matches)
|
call s:Uniq(matches)
|
||||||
call map(matches, "'.git/' . v:val")
|
call map(matches, "'.git/' . v:val")
|
||||||
|
elseif base =~# '^\~/'
|
||||||
|
let matches = map(s:GlobComplete(expand('~/'), base[2:-1] . '*'), '"~/" . v:val')
|
||||||
elseif len(tree) > 1
|
elseif len(tree) > 1
|
||||||
let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*')
|
let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*')
|
||||||
else
|
else
|
||||||
let matches = []
|
let matches = []
|
||||||
endif
|
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))')
|
call map(matches, 's:fnameescape(s:Slash(matchstr(a:base, strip) . v:val))')
|
||||||
return matches
|
return matches
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user