diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 822d31814..441802a58 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -104,13 +104,20 @@ pub enum DebugConfigCompletion { Advanced(AdvancedCompletion), } +#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[serde(untagged)] +pub enum DebugArgumentValue { + String(String), + Array(Vec), +} + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct DebugTemplate { pub name: String, pub request: String, pub completion: Vec, - pub args: HashMap, + pub args: HashMap, } #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index 6df9be226..566730e1a 100644 --- a/helix-term/src/commands/dap.rs +++ b/helix-term/src/commands/dap.rs @@ -5,7 +5,10 @@ use crate::{ job::Callback, ui::{FilePicker, Prompt, PromptEvent}, }; -use helix_core::{syntax::DebugConfigCompletion, Selection}; +use helix_core::{ + syntax::{DebugArgumentValue, DebugConfigCompletion}, + Selection, +}; use helix_dap::{self as dap, Client, ThreadId}; use helix_lsp::block_on; @@ -239,13 +242,26 @@ pub fn dap_start_impl( } } // For param #0 replace {0} in args - value = value.replace(format!("{{{}}}", i).as_str(), ¶m); + value = match value { + DebugArgumentValue::String(v) => { + DebugArgumentValue::String(v.replace(format!("{{{}}}", i).as_str(), ¶m)) + } + DebugArgumentValue::Array(arr) => DebugArgumentValue::Array( + arr.iter() + .map(|v| v.replace(format!("{{{}}}", i).as_str(), ¶m)) + .collect(), + ), + }; } - if let Ok(integer) = value.parse::() { - args.insert(k, Value::Number(serde_json::Number::from(integer))); - } else { - args.insert(k, Value::String(value)); + if let DebugArgumentValue::String(string) = value { + if let Ok(integer) = string.parse::() { + args.insert(k, to_value(integer).unwrap()); + } else { + args.insert(k, to_value(string).unwrap()); + } + } else if let DebugArgumentValue::Array(arr) = value { + args.insert(k, to_value(arr).unwrap()); } } }