@@ -102,25 +102,16 @@ impl Terminal {
102102    } 
103103
104104    pub  fn  set_default_compreply ( & mut  self ,  core :  & mut  ShellCore )  -> bool  { 
105- 
106105        let  pos = core. data . get_param ( "COMP_CWORD" ) . to_string ( ) ; 
107106        let  last = core. data . get_array ( "COMP_WORDS" ,  & pos) ; 
108107
108+         let  com = core. data . get_array ( "COMP_WORDS" ,  "0" ) ; 
109+ 
109110        let  ( tilde_prefix,  tilde_path,  last_tilde_expanded)  = Self :: set_tilde_transform ( & last,  core) ; 
110111
111112        let  mut  args = vec ! [ "" . to_string( ) ,  "" . to_string( ) ,  last_tilde_expanded. to_string( ) ] ; 
112-         let  list = match  pos == "0"  { 
113-             true   => { 
114-                 if  core. data . get_array_len ( "COMP_WORDS" )  == 0  { 
115-                     self . escape_at_completion  = false ; 
116-                     completion:: compgen_h ( core,  & mut  args) . to_vec ( ) . into_iter ( ) . filter ( |h| h. len ( )  > 0 ) . collect ( ) 
117-                 } else { 
118-                     completion:: compgen_c ( core,  & mut  args) 
119-                 } 
120-             } , 
121-             false  => completion:: compgen_f ( core,  & mut  args) , 
122-         } ; 
123113
114+         let  list = self . make_default_compreply ( core,  & mut  args,  & com,  & pos) ; 
124115        if  list. len ( )  == 0  { 
125116            return  false ; 
126117        } 
@@ -130,6 +121,26 @@ impl Terminal {
130121        true 
131122    } 
132123
124+     fn  make_default_compreply ( & mut  self ,  core :  & mut  ShellCore ,  args :  & mut  Vec < String > , 
125+                               com :  & str ,  pos :  & str )  -> Vec < String >  { 
126+         if  let  Some ( action)  = core. completion_actions . get ( com)  { 
127+             if  action == "user"  { 
128+                 return  completion:: compgen_u ( core,  args) ; 
129+             } 
130+         } 
131+ 
132+         if  pos == "0"  { 
133+             return  if  core. data . get_array_len ( "COMP_WORDS" )  == 0  { 
134+                 self . escape_at_completion  = false ; 
135+                 completion:: compgen_h ( core,  args) . to_vec ( ) . into_iter ( ) . filter ( |h| h. len ( )  > 0 ) . collect ( ) 
136+             } else { 
137+                 completion:: compgen_c ( core,  args) 
138+             } ; 
139+         } 
140+ 
141+         completion:: compgen_f ( core,  args) 
142+     } 
143+ 
133144    pub  fn  try_completion ( & mut  self ,  core :  & mut  ShellCore )  { 
134145        let  pos = core. data . get_param ( "COMP_CWORD" ) . to_string ( ) ; 
135146        let  target = core. data . get_array ( "COMP_WORDS" ,  & pos) ; 
0 commit comments