@@ -30,7 +30,11 @@ GitAdapter.Rev = GitRev
3030
3131--- @return string , string
3232function M .pathspec_split (pathspec )
33- local magic = pathspec :match (" ^:[/!^]*:?" ) or pathspec :match (" ^:%b()" ) or " "
33+ local magic = utils .str_match (pathspec , {
34+ " ^:[/!^]+:?" ,
35+ " ^:%b()" ,
36+ " ^:" ,
37+ }) or " "
3438 local pattern = pathspec :sub (1 + # magic , - 1 )
3539 return magic or " " , pattern or " "
3640end
@@ -1572,7 +1576,10 @@ GitAdapter.flags = {
15721576 end , value )
15731577 ), " " )
15741578 end ,
1575- completion = function (_ )
1579+ --- @param panel FHOptionPanel
1580+ completion = function (panel )
1581+ local view = panel .parent .parent
1582+
15761583 return function (_ , cmd_line , cur_pos )
15771584 local ok , ctx = pcall (arg_parser .scan_sh_args , cmd_line , cur_pos )
15781585
@@ -1586,7 +1593,7 @@ GitAdapter.flags = {
15861593 utils .vec_slice (quoted , 1 , ctx .argidx - 1 ),
15871594 utils .str_quote (v , { only_if_whitespace = true })
15881595 ), " " )
1589- end , vim . fn . getcompletion (ctx .arg_lead , " file " ))
1596+ end , view . adapter : path_completion (ctx .arg_lead ))
15901597 end
15911598 end
15921599 end ,
@@ -1641,6 +1648,14 @@ end
16411648
16421649-- Completion
16431650
1651+ function GitAdapter :path_completion (arg_lead )
1652+ local magic , pattern = M .pathspec_split (arg_lead )
1653+
1654+ return vim .tbl_map (function (v )
1655+ return magic .. v
1656+ end , vim .fn .getcompletion (pattern , " file" , 0 ))
1657+ end
1658+
16441659function GitAdapter :rev_candidates ()
16451660 logger .lvl (1 ).debug (" [completion] Revision candidates requested." )
16461661 -- stylua: ignore start
0 commit comments