debugger: Support passing custom arguments to debug adapters (#33251)
Custom arguments replace any arguments that we normally pass to the DAP. For interpreted languages, they are passed to the interpreter after the DAP path or module. They can be combined with a custom binary, or you can omit `dap.binary` and just customize the arguments to the DAPs we download. This doesn't take care of updating the extension API to support custom arguments. Release Notes: - debugger: Implemented support for passing custom arguments to a debug adapter binary using the `dap.args` setting. - debugger: Fixed not being able to use the `dap` setting in `.zed/settings.json`.
This commit is contained in:
parent
a067c16c82
commit
c9bd409732
11 changed files with 154 additions and 54 deletions
|
@ -50,6 +50,7 @@ impl JsDebugAdapter {
|
|||
delegate: &Arc<dyn DapDelegate>,
|
||||
task_definition: &DebugTaskDefinition,
|
||||
user_installed_path: Option<PathBuf>,
|
||||
user_args: Option<Vec<String>>,
|
||||
_: &mut AsyncApp,
|
||||
) -> Result<DebugAdapterBinary> {
|
||||
let adapter_path = if let Some(user_installed_path) = user_installed_path {
|
||||
|
@ -109,6 +110,26 @@ impl JsDebugAdapter {
|
|||
.or_insert(true.into());
|
||||
}
|
||||
|
||||
let arguments = if let Some(mut args) = user_args {
|
||||
args.insert(
|
||||
0,
|
||||
adapter_path
|
||||
.join(Self::ADAPTER_PATH)
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
);
|
||||
args
|
||||
} else {
|
||||
vec![
|
||||
adapter_path
|
||||
.join(Self::ADAPTER_PATH)
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
port.to_string(),
|
||||
host.to_string(),
|
||||
]
|
||||
};
|
||||
|
||||
Ok(DebugAdapterBinary {
|
||||
command: Some(
|
||||
delegate
|
||||
|
@ -118,14 +139,7 @@ impl JsDebugAdapter {
|
|||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
),
|
||||
arguments: vec![
|
||||
adapter_path
|
||||
.join(Self::ADAPTER_PATH)
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
port.to_string(),
|
||||
host.to_string(),
|
||||
],
|
||||
arguments,
|
||||
cwd: Some(delegate.worktree_root_path().to_path_buf()),
|
||||
envs: HashMap::default(),
|
||||
connection: Some(adapters::TcpArguments {
|
||||
|
@ -464,6 +478,7 @@ impl DebugAdapter for JsDebugAdapter {
|
|||
delegate: &Arc<dyn DapDelegate>,
|
||||
config: &DebugTaskDefinition,
|
||||
user_installed_path: Option<PathBuf>,
|
||||
user_args: Option<Vec<String>>,
|
||||
cx: &mut AsyncApp,
|
||||
) -> Result<DebugAdapterBinary> {
|
||||
if self.checked.set(()).is_ok() {
|
||||
|
@ -481,7 +496,7 @@ impl DebugAdapter for JsDebugAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
self.get_installed_binary(delegate, &config, user_installed_path, cx)
|
||||
self.get_installed_binary(delegate, &config, user_installed_path, user_args, cx)
|
||||
.await
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue