@@ -102,25 +102,16 @@ impl Terminal {
102
102
}
103
103
104
104
pub fn set_default_compreply ( & mut self , core : & mut ShellCore ) -> bool {
105
-
106
105
let pos = core. data . get_param ( "COMP_CWORD" ) . to_string ( ) ;
107
106
let last = core. data . get_array ( "COMP_WORDS" , & pos) ;
108
107
108
+ let com = core. data . get_array ( "COMP_WORDS" , "0" ) ;
109
+
109
110
let ( tilde_prefix, tilde_path, last_tilde_expanded) = Self :: set_tilde_transform ( & last, core) ;
110
111
111
112
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
- } ;
123
113
114
+ let list = self . make_default_compreply ( core, & mut args, & com, & pos) ;
124
115
if list. len ( ) == 0 {
125
116
return false ;
126
117
}
@@ -130,6 +121,26 @@ impl Terminal {
130
121
true
131
122
}
132
123
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
+
133
144
pub fn try_completion ( & mut self , core : & mut ShellCore ) {
134
145
let pos = core. data . get_param ( "COMP_CWORD" ) . to_string ( ) ;
135
146
let target = core. data . get_array ( "COMP_WORDS" , & pos) ;
0 commit comments