on master help sign in
dap: support arrays as arguments
6aa9838Dmitry Sharshakov
helix-core/src/syntax.rs+8−1
@@ -104,13 +104,20 @@ pub enum DebugConfigCompletion {
104 Advanced(AdvancedCompletion),
104 Advanced(AdvancedCompletion),
105}
105}
106
106
107+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
108+#[serde(untagged)]
109+pub enum DebugArgumentValue {
110+ String(String),
111+ Array(Vec<String>),
112+}
113+
107#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
114#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
108#[serde(rename_all = "kebab-case")]
115#[serde(rename_all = "kebab-case")]
109pub struct DebugTemplate {
116pub struct DebugTemplate {
110 pub name: String,
117 pub name: String,
111 pub request: String,
118 pub request: String,
112 pub completion: Vec<DebugConfigCompletion>,
119 pub completion: Vec<DebugConfigCompletion>,
113− pub args: HashMap<String, String>,
120+ pub args: HashMap<String, DebugArgumentValue>,
114}
121}
115
122
116#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
123#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
helix-term/src/commands/dap.rs+22−6
@@ -5,7 +5,10 @@ use crate::{
5 job::Callback,
5 job::Callback,
6 ui::{FilePicker, Prompt, PromptEvent},
6 ui::{FilePicker, Prompt, PromptEvent},
7};
7};
8+use helix_core::{
8−use helix_core::{syntax::DebugConfigCompletion, Selection};
9+ syntax::{DebugArgumentValue, DebugConfigCompletion},
10+ Selection,
11+};
9use helix_dap::{self as dap, Client, ThreadId};
12use helix_dap::{self as dap, Client, ThreadId};
10use helix_lsp::block_on;
13use helix_lsp::block_on;
11
14
@@ -239,13 +242,26 @@ pub fn dap_start_impl(
239 }
242 }
240 }
243 }
241 // For param #0 replace {0} in args
244 // For param #0 replace {0} in args
245+ value = match value {
246+ DebugArgumentValue::String(v) => {
242− value = value.replace(format!("{{{}}}", i).as_str(), &param);
247+ DebugArgumentValue::String(v.replace(format!("{{{}}}", i).as_str(), &param))
248+ }
249+ DebugArgumentValue::Array(arr) => DebugArgumentValue::Array(
250+ arr.iter()
251+ .map(|v| v.replace(format!("{{{}}}", i).as_str(), &param))
252+ .collect(),
253+ ),
254+ };
243 }
255 }
244
256
257+ if let DebugArgumentValue::String(string) = value {
245− if let Ok(integer) = value.parse::<usize>() {
258+ if let Ok(integer) = string.parse::<usize>() {
246− args.insert(k, Value::Number(serde_json::Number::from(integer)));
259+ args.insert(k, to_value(integer).unwrap());
247− } else {
260+ } else {
248− args.insert(k, Value::String(value));
261+ args.insert(k, to_value(string).unwrap());
262+ }
263+ } else if let DebugArgumentValue::Array(arr) = value {
264+ args.insert(k, to_value(arr).unwrap());
249 }
265 }
250 }
266 }
251 }
267 }