@@ -2415,6 +2415,17 @@ function! s:CompleteHeads(dir) abort
2415
2415
\ sort (s: LinesError ([a: dir , ' rev-parse' , ' --symbolic' , ' --branches' , ' --tags' , ' --remotes' ])[0 ])
2416
2416
endfunction
2417
2417
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
+
2418
2429
function ! fugitive#CompleteObject (base, ... ) abort
2419
2430
let dir = a: 0 == 1 ? a: 1 : a: 0 >= 3 ? a: 3 : s: Dir ()
2420
2431
let tree = s: Tree (dir )
@@ -2424,9 +2435,10 @@ function! fugitive#CompleteObject(base, ...) abort
2424
2435
let subdir = strpart (cwd, len (tree) + 1 ) . ' /'
2425
2436
endif
2426
2437
let base = s: Expand (a: base )
2438
+ let [pre , base] = s: SplitRevRange (base, ' ^[^:]*\/\@<!\.\.\.\=[\/\.]\@!' )
2427
2439
2428
2440
if a: base = ~# ' ^!\d*$' && base !~# ' ^!'
2429
- return [base]
2441
+ return [pre . base]
2430
2442
elseif base = ~# ' ^\.\=/\|^:(' || base !~# ' :'
2431
2443
let results = []
2432
2444
if base = ~# ' ^refs/'
@@ -2442,6 +2454,7 @@ function! fugitive#CompleteObject(base, ...) abort
2442
2454
let results += s: FilterEscape (heads, fnameescape (base))
2443
2455
endif
2444
2456
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' )
2445
2458
return results
2446
2459
2447
2460
elseif base = ~# ' ^:'
@@ -2461,7 +2474,7 @@ function! fugitive#CompleteObject(base, ...) abort
2461
2474
call map (entries,' s:sub(v:val,"^04.*\\zs$","/")' )
2462
2475
call map (entries,' parent.s:sub(v:val,".*\t","")' )
2463
2476
endif
2464
- return s: FilterEscape (entries, fnameescape (base))
2477
+ return map ( s: FilterEscape (entries, fnameescape (base)), ' pre . v:val ' )
2465
2478
endfunction
2466
2479
2467
2480
function ! s: CompleteSub (subcommand, A, L, P , ... ) abort
0 commit comments