Account for optional escaping in tab complete

Tab complete results are always passed to fnameescape(), which can
result in the output having more backslashes than the input, causing
those results to be filtered out.  Attempt to reconcile this.

References: https://github.com/tpope/vim-fugitive/issues/1916
This commit is contained in:
Tim Pope
2022-01-05 10:59:51 -05:00
parent b6dbb97759
commit 88a97127d1

View File

@@ -2328,12 +2328,14 @@ call s:add_methods('buffer', ['repo', 'type'])
function! s:FilterEscape(items, ...) abort
let items = copy(a:items)
call map(items, 's:fnameescape(v:val)')
if a:0 && type(a:1) == type('')
let cmp = s:FileIgnoreCase(1) ? '==?' : '==#'
call filter(items, 'strpart(v:val, 0, strlen(a:1)) ' . cmp . ' a:1')
call map(items, 'fnameescape(v:val)')
if !a:0 || type(a:1) != type('')
let match = ''
else
let match = substitute(a:1, '^[+>]\|\\\@<![' . substitute(s:fnameescape, '\\', '', '') . ']', '\\&', 'g')
endif
return items
let cmp = s:FileIgnoreCase(1) ? '==?' : '==#'
return filter(items, 'strpart(v:val, 0, strlen(match)) ' . cmp . ' match')
endfunction
function! s:GlobComplete(lead, pattern, ...) abort