1
1
use std:: { borrow:: Cow , mem, time:: Duration } ;
2
2
3
- use anyhow:: bail;
4
3
use tokio:: pin;
5
4
use tokio_stream:: { StreamExt , wrappers:: UnboundedReceiverStream } ;
6
5
use tracing:: error;
@@ -13,22 +12,18 @@ use crate::tab::Tab;
13
12
14
13
impl Tab {
15
14
pub fn search ( & mut self , opt : impl TryInto < SearchOpt > ) {
16
- let Ok ( mut opt) = opt. try_into ( ) else {
15
+ let Ok ( mut opt) : Result < SearchOpt , _ > = opt. try_into ( ) else {
17
16
return AppProxy :: notify_error ( "Invalid `search` option" , "Failed to parse search option" ) ;
18
17
} ;
19
18
20
- if opt. via == SearchOptVia :: None {
21
- return self . search_stop ( ) ;
22
- }
23
-
24
19
if let Some ( handle) = self . search . take ( ) {
25
20
handle. abort ( ) ;
26
21
}
27
22
28
- tokio:: spawn ( async move {
29
- let mut input =
30
- InputProxy :: show ( InputCfg :: search ( & opt. via . to_string ( ) ) . with_value ( opt. subject ) ) ;
23
+ let mut input =
24
+ InputProxy :: show ( InputCfg :: search ( opt. via . as_ref ( ) ) . with_value ( opt. subject . to_owned ( ) ) ) ;
31
25
26
+ tokio:: spawn ( async move {
32
27
if let Some ( Ok ( subject) ) = input. recv ( ) . await {
33
28
opt. subject = Cow :: Owned ( subject) ;
34
29
TabProxy :: search_do ( opt) ;
@@ -68,7 +63,6 @@ impl Tab {
68
63
subject : opt. subject . into_owned ( ) ,
69
64
args : opt. args ,
70
65
} ) ,
71
- SearchOptVia :: None => bail ! ( "Invalid `via` option for `search` command" ) ,
72
66
} ?;
73
67
74
68
let rx = UnboundedReceiverStream :: new ( rx) . chunks_timeout ( 5000 , Duration :: from_millis ( 500 ) ) ;
0 commit comments