Skip to content

Commit 55c1b6e

Browse files
committed
feat(find): Inform user if fdfind is not installed
1 parent bb4440e commit 55c1b6e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

plugins/src/find/mod.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ pub async fn main() {
4949
}
5050
}
5151

52-
Event::Search(search) => app.search(search).await,
52+
Event::Search(search) => {
53+
app.search(search).await;
54+
app.active.set(false);
55+
crate::send(&mut app.out, PluginResponse::Finished).await;
56+
},
5357
}
5458
}
5559
};
@@ -142,18 +146,31 @@ impl SearchContext {
142146

143147
/// Submits the query to `fdfind` and actively monitors the search results while handling interrupts.
144148
async fn search(&mut self, search: String) {
149+
self.search_results.clear();
145150
tracing::debug!("searching for {}", search);
146151

147152
let (mut child, mut stdout) = match query(&search).await {
148153
Ok((child, stdout)) => (child, futures_lite::io::BufReader::new(stdout).lines()),
149154
Err(why) => {
150155
tracing::error!("failed to spawn fdfind process: {}", why);
151-
self.active.set(false);
156+
157+
let _ = crate::send(
158+
&mut self.out,
159+
PluginResponse::Append(PluginSearchResult {
160+
id: 0,
161+
name: if why.kind() == io::ErrorKind::NotFound {
162+
String::from("fdfind command is not installed")
163+
} else {
164+
format!("failed to spawn fdfind process: {}", why)
165+
},
166+
..Default::default()
167+
}),
168+
).await;
169+
152170
return;
153171
}
154172
};
155173

156-
self.search_results.clear();
157174
let mut id = 0;
158175
let mut append;
159176

@@ -184,8 +201,6 @@ impl SearchContext {
184201
}
185202
}
186203

187-
crate::send(&mut self.out, PluginResponse::Finished).await;
188-
self.active.set(false);
189204
let _ = child.kill();
190205
let _ = child.status().await;
191206
}

0 commit comments

Comments
 (0)