From 6aa9838ea6c4c4a355796ef6dcc4dd28f2035c38 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sun, 24 Oct 2021 17:24:18 +0300 Subject: dap: support arrays as arguments --- helix-term/src/commands/dap.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index 6df9be22..566730e1 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()); } } } -- cgit v1.2.3-70-g09d2