Skip to content

Commit b7453ac

Browse files
authored
Ensure command args aren't parsed by rdbg (#128)
Ensure that all commands and arguments come after an options terminator, as heavily recommended by [rdbg](https://github.com/ruby/debug?tab=readme-ov-file#use-rdbg-with-commands-written-in-ruby) themselves. This ensures that rdbg doesn't attempt to parse and delete options that are meant for the program.
1 parent ca5a38b commit b7453ac

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/ruby.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,17 @@ impl zed::Extension for RubyExtension {
202202
if let Some(script) = &ruby_config.script {
203203
arguments.push(script.clone());
204204
} else if let Some(command) = &ruby_config.command {
205-
arguments.push("--command".to_string());
206-
arguments.push(command.clone());
205+
arguments.extend(["--command".into(), "--".into(), command.clone()]);
207206
} else if let Some(command_or_script) = &ruby_config.script_or_command {
208207
if worktree.which(command_or_script).is_some() {
209-
arguments.push("--command".to_string());
208+
arguments.extend([
209+
"--command".into(),
210+
"--".into(),
211+
command_or_script.clone(),
212+
]);
213+
} else {
214+
arguments.push(command_or_script.clone());
210215
}
211-
arguments.push(command_or_script.clone());
212216
} else {
213217
return Err("Ruby debug config must have 'script' or 'command' args".into());
214218
}
@@ -218,6 +222,10 @@ impl zed::Extension for RubyExtension {
218222
}
219223
}
220224

225+
if !arguments.contains(&"--command".to_string()) {
226+
// Ensure that all arguments are passed after a "--", as required by rdbg.
227+
arguments.push("--".into());
228+
}
221229
arguments.extend(ruby_config.args);
222230

223231
if use_bundler {

0 commit comments

Comments
 (0)