commit 2c6bd3bd2d577ccebe773ca1ae47d0ce0ebcc02d (tree)
parent aae36024b89e34db0280b5361633fb036b17951f
Author: Tim Pope <code@tpope.net>
Date: Fri, 20 Aug 2021 11:47:18 -0400
Improve tab completion for :Git push
References: https://github.com/tpope/vim-fugitive/issues/1813
Diffstat:
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -5841,8 +5841,24 @@ endfunction
" Section: :Git push, :Git fetch
+function! s:CompletePush(A, L, P, ...) abort
+ let dir = a:0 ? a:1 : s:Dir()
+ let remote = matchstr(a:L, '\u\w*[! ] *.\{-\}\s\@<=\zs[^-[:space:]]\S*\ze ')
+ if empty(remote)
+ let matches = s:LinesError([dir, 'remote'])[0]
+ elseif a:A =~# ':'
+ let lead = matchstr(a:A, '^[^:]*:')
+ let matches = s:LinesError([dir, 'ls-remote', remote])[0]
+ call filter(matches, 'v:val =~# "\t" && v:val !~# "{"')
+ call map(matches, 'lead . s:sub(v:val, "^.*\t", "")')
+ else
+ let matches = s:CompleteHeads(dir)
+ endif
+ return s:FilterEscape(matches, a:A)
+endfunction
+
function! fugitive#PushComplete(A, L, P, ...) abort
- return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote'), a:000)
+ return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompletePush'), a:000)
endfunction
function! fugitive#FetchComplete(A, L, P, ...) abort