@@ -2415,6 +2415,17 @@ function! s:CompleteHeads(dir) abort
24152415 \ sort (s: LinesError ([a: dir , ' rev-parse' , ' --symbolic' , ' --branches' , ' --tags' , ' --remotes' ])[0 ])
24162416endfunction
24172417
2418+ function ! s: SplitRevRange (base, pat)
2419+ let index = matchend (a: base , a: pat )
2420+ if index == -1
2421+ return [' ' , a: base ]
2422+ endif
2423+ let pre = a: base [:index - 1 ]
2424+ let base = a: base [index :]
2425+ return [pre , base]
2426+ endif
2427+ endfunction
2428+
24182429function ! fugitive#CompleteObject (base, ... ) abort
24192430 let dir = a: 0 == 1 ? a: 1 : a: 0 >= 3 ? a: 3 : s: Dir ()
24202431 let tree = s: Tree (dir )
@@ -2424,9 +2435,10 @@ function! fugitive#CompleteObject(base, ...) abort
24242435 let subdir = strpart (cwd, len (tree) + 1 ) . ' /'
24252436 endif
24262437 let base = s: Expand (a: base )
2438+ let [pre , base] = s: SplitRevRange (base, ' ^[^:]*\/\@<!\.\.\.\=[\/\.]\@!' )
24272439
24282440 if a: base = ~# ' ^!\d*$' && base !~# ' ^!'
2429- return [base]
2441+ return [pre . base]
24302442 elseif base = ~# ' ^\.\=/\|^:(' || base !~# ' :'
24312443 let results = []
24322444 if base = ~# ' ^refs/'
@@ -2442,6 +2454,7 @@ function! fugitive#CompleteObject(base, ...) abort
24422454 let results += s: FilterEscape (heads, fnameescape (base))
24432455 endif
24442456 let results += a: 0 == 1 || a: 0 >= 3 ? fugitive#CompletePath (base, 0 , ' ' , dir , a: 0 >= 4 ? a: 4 : tree) : fugitive#CompletePath (base)
2457+ let results = map (results, ' pre . v:val' )
24452458 return results
24462459
24472460 elseif base = ~# ' ^:'
@@ -2461,7 +2474,7 @@ function! fugitive#CompleteObject(base, ...) abort
24612474 call map (entries,' s:sub(v:val,"^04.*\\zs$","/")' )
24622475 call map (entries,' parent.s:sub(v:val,".*\t","")' )
24632476 endif
2464- return s: FilterEscape (entries, fnameescape (base))
2477+ return map ( s: FilterEscape (entries, fnameescape (base)), ' pre . v:val ' )
24652478endfunction
24662479
24672480function ! s: CompleteSub (subcommand, A, L, P , ... ) abort
0 commit comments