DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Search/
FindInFiles.rs1use std::sync::Arc;
5
6use serde_json::{Value, json};
7
8use crate::{
9 IPC::WindServiceHandlers::Utilities::JsonValueHelpers::arg_bool,
10 RunTime::ApplicationRunTime::ApplicationRunTime,
11 dev_log,
12};
13
14pub async fn Fn(RunTime:Arc<ApplicationRunTime>, mut Arguments:Vec<Value>) -> Result<Value, String> {
15 use CommonLibrary::Search::SearchProvider::SearchProvider;
16
17 let QueryValue = if Arguments.first().map(|V| V.is_object()).unwrap_or(false) {
18 Arguments.remove(0)
19 } else if let Some(Pattern) = Arguments.first().and_then(|V| V.as_str()) {
20 let IsRegex = arg_bool(&Arguments, 1);
21
22 let IsCase = arg_bool(&Arguments, 2);
23
24 let IsWord = arg_bool(&Arguments, 3);
25
26 json!({
27 "pattern": Pattern,
28 "isRegex": IsRegex,
29 "isCaseSensitive": IsCase,
30 "isWordMatch": IsWord,
31 })
32 } else {
33 return Err("search:findInFiles requires pattern or TextSearchQuery".to_string());
34 };
35
36 let OptionsValue = Arguments.into_iter().next().unwrap_or(Value::Null);
37
38 dev_log!("search", "search:textSearch delegating to SearchProvider::TextSearch");
39
40 RunTime
41 .Environment
42 .TextSearch(QueryValue, OptionsValue)
43 .await
44 .map_err(|Error| Error.to_string())
45}