@@ -161,6 +161,58 @@ fn complete() {
161
161
-V --generate --version quote pacman alias complete "# ;
162
162
let actual = runtime. complete ( input, & term) . unwrap ( ) ;
163
163
snapbox:: assert_eq ( expected, actual) ;
164
+
165
+ // Issue 5239 (https://github.com/clap-rs/clap/issues/5239)
166
+ let input = "exhaustive hint --file test\t " ;
167
+ let expected = "exhaustive hint --file test % exhaustive hint --file tests " ;
168
+ let actual = runtime. complete ( input, & term) . unwrap ( ) ;
169
+ snapbox:: assert_eq ( expected, actual) ;
170
+
171
+ {
172
+ use std:: fs:: File ;
173
+ use std:: path:: Path ;
174
+
175
+ let testdir = snapbox:: path:: PathFixture :: mutable_temp ( ) . unwrap ( ) ;
176
+ let testdir_path = testdir. path ( ) . unwrap ( ) ;
177
+
178
+ File :: create ( Path :: new ( testdir_path) . join ( "a_file" ) ) . unwrap ( ) ;
179
+ File :: create ( Path :: new ( testdir_path) . join ( "b_file" ) ) . unwrap ( ) ;
180
+ std:: fs:: create_dir ( Path :: new ( testdir_path) . join ( "c_dir" ) ) . unwrap ( ) ;
181
+ std:: fs:: create_dir ( Path :: new ( testdir_path) . join ( "d_dir" ) ) . unwrap ( ) ;
182
+
183
+ let input = format ! (
184
+ "exhaustive hint --file {}/\t \t " ,
185
+ testdir_path. to_string_lossy( )
186
+ ) ;
187
+ let actual = runtime. complete ( input. as_str ( ) , & term) . unwrap ( ) ;
188
+ assert ! (
189
+ actual. contains( "a_file" )
190
+ && actual. contains( "b_file" )
191
+ && actual. contains( "c_dir" )
192
+ && actual. contains( "d_dir" ) ,
193
+ "Actual output:\n {}" ,
194
+ actual
195
+ ) ;
196
+
197
+ let input = format ! (
198
+ "exhaustive hint --dir {}/\t \t " ,
199
+ testdir_path. to_string_lossy( )
200
+ ) ;
201
+ let actual = runtime. complete ( input. as_str ( ) , & term) . unwrap ( ) ;
202
+ assert ! (
203
+ actual. contains( "a_file" )
204
+ && actual. contains( "b_file" )
205
+ && actual. contains( "c_dir" )
206
+ && actual. contains( "d_dir" ) ,
207
+ "Actual output:\n {}" ,
208
+ actual
209
+ ) ;
210
+ }
211
+
212
+ let input = "exhaustive hint --other \t " ;
213
+ let expected = "exhaustive hint --other % exhaustive hint --other " ;
214
+ let actual = runtime. complete ( input, & term) . unwrap ( ) ;
215
+ snapbox:: assert_eq ( expected, actual) ;
164
216
}
165
217
166
218
#[ test]
0 commit comments