Fix ruby debugger (#32407)

Closes #ISSUE

Release Notes:

- debugger: Fix Ruby (was broken by #30833)

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com>
Co-authored-by: Cole Miller <m@cole-miller.net>
This commit is contained in:
Conrad Irwin 2025-06-09 16:11:24 -06:00 committed by GitHub
parent b103d7621b
commit 3dfbd9e57c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 116 additions and 174 deletions

View file

@ -530,6 +530,21 @@ impl EnvVariableReplacer {
fn new(variables: HashMap<VsCodeEnvVariable, ZedEnvVariable>) -> Self {
Self { variables }
}
fn replace_value(&self, input: serde_json::Value) -> serde_json::Value {
match input {
serde_json::Value::String(s) => serde_json::Value::String(self.replace(&s)),
serde_json::Value::Array(arr) => {
serde_json::Value::Array(arr.into_iter().map(|v| self.replace_value(v)).collect())
}
serde_json::Value::Object(obj) => serde_json::Value::Object(
obj.into_iter()
.map(|(k, v)| (self.replace(&k), self.replace_value(v)))
.collect(),
),
_ => input,
}
}
// Replaces occurrences of VsCode-specific environment variables with Zed equivalents.
fn replace(&self, input: &str) -> String {
shellexpand::env_with_context_no_errors(&input, |var: &str| {

View file

@ -53,7 +53,7 @@ impl VsCodeDebugTaskDefinition {
host: None,
timeout: None,
}),
config: self.other_attributes,
config: replacer.replace_value(self.other_attributes),
};
Ok(definition)
}
@ -75,7 +75,7 @@ impl TryFrom<VsCodeDebugTaskFile> for DebugTaskFile {
"workspaceFolder".to_owned(),
VariableName::WorktreeRoot.to_string(),
),
// TODO other interesting variables?
("file".to_owned(), VariableName::Filename.to_string()), // TODO other interesting variables?
]));
let templates = file
.configurations
@ -94,6 +94,7 @@ fn task_type_to_adapter_name(task_type: &str) -> SharedString {
"php" => "PHP",
"cppdbg" | "lldb" => "CodeLLDB",
"debugpy" => "Debugpy",
"rdbg" => "Ruby",
_ => task_type,
}
.to_owned()