@@ -102,6 +102,11 @@ PROMPT='%% '
102
102
& self . home
103
103
}
104
104
105
+ /// Set the timeout for completion
106
+ pub fn timeout ( & mut self , timeout : Duration ) {
107
+ self . timeout = timeout;
108
+ }
109
+
105
110
/// Register a completion script
106
111
pub fn register ( & mut self , name : & str , content : & str ) -> std:: io:: Result < ( ) > {
107
112
let path = self . home . join ( format ! ( "zsh/_{name}" ) ) ;
@@ -110,15 +115,20 @@ PROMPT='%% '
110
115
}
111
116
112
117
/// Get the output from typing `input` into the shell
113
- pub fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
118
+ pub fn complete (
119
+ & mut self ,
120
+ input : & str ,
121
+ term : & Term ,
122
+ timeout : Duration ,
123
+ ) -> std:: io:: Result < String > {
114
124
let mut command = Command :: new ( "zsh" ) ;
115
125
command. arg ( "--noglobalrcs" ) ;
116
126
command
117
127
. env ( "PATH" , & self . path )
118
128
. env ( "TERM" , "xterm" )
119
129
. env ( "ZDOTDIR" , & self . home ) ;
120
130
let echo = false ;
121
- comptest ( command, echo, input, term, self . timeout )
131
+ comptest ( command, echo, input, term, timeout)
122
132
}
123
133
}
124
134
@@ -132,7 +142,7 @@ impl Runtime for ZshRuntime {
132
142
}
133
143
134
144
fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
135
- self . complete ( input, term)
145
+ self . complete ( input, term, self . timeout )
136
146
}
137
147
}
138
148
@@ -207,6 +217,11 @@ PS1='% '
207
217
& self . home
208
218
}
209
219
220
+ /// Set the timeout for completion
221
+ pub fn timeout ( & mut self , timeout : Duration ) {
222
+ self . timeout = timeout;
223
+ }
224
+
210
225
/// Register a completion script
211
226
pub fn register ( & mut self , _name : & str , content : & str ) -> std:: io:: Result < ( ) > {
212
227
let mut file = std:: fs:: OpenOptions :: new ( )
@@ -217,7 +232,12 @@ PS1='% '
217
232
}
218
233
219
234
/// Get the output from typing `input` into the shell
220
- pub fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
235
+ pub fn complete (
236
+ & mut self ,
237
+ input : & str ,
238
+ term : & Term ,
239
+ timeout : Duration ,
240
+ ) -> std:: io:: Result < String > {
221
241
let mut command = Command :: new ( "bash" ) ;
222
242
let inputrc_path = self . home . join ( ".inputrc" ) ;
223
243
command
@@ -226,7 +246,7 @@ PS1='% '
226
246
. env ( "INPUTRC" , & inputrc_path)
227
247
. args ( [ OsStr :: new ( "--rcfile" ) , self . config . as_os_str ( ) ] ) ;
228
248
let echo = !input. contains ( "\t \t " ) ;
229
- comptest ( command, echo, input, term, self . timeout )
249
+ comptest ( command, echo, input, term, timeout)
230
250
}
231
251
}
232
252
@@ -240,7 +260,7 @@ impl Runtime for BashRuntime {
240
260
}
241
261
242
262
fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
243
- self . complete ( input, term)
263
+ self . complete ( input, term, self . timeout )
244
264
}
245
265
}
246
266
@@ -312,6 +332,11 @@ end;
312
332
& self . home
313
333
}
314
334
335
+ /// Set the timeout for completion
336
+ pub fn timeout ( & mut self , timeout : Duration ) {
337
+ self . timeout = timeout;
338
+ }
339
+
315
340
/// Register a completion script
316
341
pub fn register ( & mut self , name : & str , content : & str ) -> std:: io:: Result < ( ) > {
317
342
let path = self . home . join ( format ! ( "fish/completions/{name}.fish" ) ) ;
@@ -320,15 +345,20 @@ end;
320
345
}
321
346
322
347
/// Get the output from typing `input` into the shell
323
- pub fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
348
+ pub fn complete (
349
+ & mut self ,
350
+ input : & str ,
351
+ term : & Term ,
352
+ timeout : Duration ,
353
+ ) -> std:: io:: Result < String > {
324
354
let mut command = Command :: new ( "fish" ) ;
325
355
command
326
356
. env ( "PATH" , & self . path )
327
357
// fish requires TERM to be set.
328
358
. env ( "TERM" , "xterm" )
329
359
. env ( "XDG_CONFIG_HOME" , & self . home ) ;
330
360
let echo = false ;
331
- comptest ( command, echo, input, term, self . timeout )
361
+ comptest ( command, echo, input, term, timeout)
332
362
}
333
363
}
334
364
@@ -342,7 +372,7 @@ impl Runtime for FishRuntime {
342
372
}
343
373
344
374
fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
345
- self . complete ( input, term)
375
+ self . complete ( input, term, self . timeout )
346
376
}
347
377
}
348
378
@@ -412,6 +442,11 @@ set edit:prompt = (constantly \"% \")
412
442
& self . home
413
443
}
414
444
445
+ /// Set the timeout for completion
446
+ pub fn timeout ( & mut self , timeout : Duration ) {
447
+ self . timeout = timeout;
448
+ }
449
+
415
450
/// Register a completion script
416
451
pub fn register ( & mut self , _name : & str , content : & str ) -> std:: io:: Result < ( ) > {
417
452
let mut file = std:: fs:: OpenOptions :: new ( )
@@ -422,13 +457,18 @@ set edit:prompt = (constantly \"% \")
422
457
}
423
458
424
459
/// Get the output from typing `input` into the shell
425
- pub fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
460
+ pub fn complete (
461
+ & mut self ,
462
+ input : & str ,
463
+ term : & Term ,
464
+ timeout : Duration ,
465
+ ) -> std:: io:: Result < String > {
426
466
let mut command = Command :: new ( "elvish" ) ;
427
467
command
428
468
. env ( "PATH" , & self . path )
429
469
. env ( "XDG_CONFIG_HOME" , & self . home ) ;
430
470
let echo = false ;
431
- comptest ( command, echo, input, term, self . timeout )
471
+ comptest ( command, echo, input, term, timeout)
432
472
}
433
473
}
434
474
@@ -442,7 +482,7 @@ impl Runtime for ElvishRuntime {
442
482
}
443
483
444
484
fn complete ( & mut self , input : & str , term : & Term ) -> std:: io:: Result < String > {
445
- self . complete ( input, term)
485
+ self . complete ( input, term, self . timeout )
446
486
}
447
487
}
448
488
0 commit comments