debugger: Interpret user-specified debug adapter binary paths in a more intuitive way for JS and Python (#33926)
Previously we would append `js-debug/src/dapDebugServer.js` to the value of the `dap.JavaScript.binary` setting and `src/debugpy/adapter` to the value of the `dap.Debugpy.binary` setting, which isn't particularly intuitive. This PR fixes that. Release Notes: - debugger: Made the semantics of the `dap.$ADAPTER.binary` setting more intuitive for the `JavaScript` and `Debugpy` adapters. In the new semantics, this should be the path to `dapDebugServer.js` for `JavaScript` and the path to the `src/debugpy/adapter` directory for `Debugpy`. --------- Co-authored-by: Remco Smits <djsmits12@gmail.com>
This commit is contained in:
parent
0ebbeec11c
commit
0a3ef40c2f
2 changed files with 20 additions and 33 deletions
|
@ -54,20 +54,6 @@ impl JsDebugAdapter {
|
||||||
user_args: Option<Vec<String>>,
|
user_args: Option<Vec<String>>,
|
||||||
_: &mut AsyncApp,
|
_: &mut AsyncApp,
|
||||||
) -> Result<DebugAdapterBinary> {
|
) -> Result<DebugAdapterBinary> {
|
||||||
let adapter_path = if let Some(user_installed_path) = user_installed_path {
|
|
||||||
user_installed_path
|
|
||||||
} else {
|
|
||||||
let adapter_path = paths::debug_adapters_dir().join(self.name().as_ref());
|
|
||||||
|
|
||||||
let file_name_prefix = format!("{}_", self.name());
|
|
||||||
|
|
||||||
util::fs::find_file_name_in_dir(adapter_path.as_path(), |file_name| {
|
|
||||||
file_name.starts_with(&file_name_prefix)
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.context("Couldn't find JavaScript dap directory")?
|
|
||||||
};
|
|
||||||
|
|
||||||
let tcp_connection = task_definition.tcp_connection.clone().unwrap_or_default();
|
let tcp_connection = task_definition.tcp_connection.clone().unwrap_or_default();
|
||||||
let (host, port, timeout) = crate::configure_tcp_connection(tcp_connection).await?;
|
let (host, port, timeout) = crate::configure_tcp_connection(tcp_connection).await?;
|
||||||
|
|
||||||
|
@ -136,21 +122,27 @@ impl JsDebugAdapter {
|
||||||
.or_insert(true.into());
|
.or_insert(true.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let adapter_path = if let Some(user_installed_path) = user_installed_path {
|
||||||
|
user_installed_path
|
||||||
|
} else {
|
||||||
|
let adapter_path = paths::debug_adapters_dir().join(self.name().as_ref());
|
||||||
|
|
||||||
|
let file_name_prefix = format!("{}_", self.name());
|
||||||
|
|
||||||
|
util::fs::find_file_name_in_dir(adapter_path.as_path(), |file_name| {
|
||||||
|
file_name.starts_with(&file_name_prefix)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.context("Couldn't find JavaScript dap directory")?
|
||||||
|
.join(Self::ADAPTER_PATH)
|
||||||
|
};
|
||||||
|
|
||||||
let arguments = if let Some(mut args) = user_args {
|
let arguments = if let Some(mut args) = user_args {
|
||||||
args.insert(
|
args.insert(0, adapter_path.to_string_lossy().to_string());
|
||||||
0,
|
|
||||||
adapter_path
|
|
||||||
.join(Self::ADAPTER_PATH)
|
|
||||||
.to_string_lossy()
|
|
||||||
.to_string(),
|
|
||||||
);
|
|
||||||
args
|
args
|
||||||
} else {
|
} else {
|
||||||
vec![
|
vec![
|
||||||
adapter_path
|
adapter_path.to_string_lossy().to_string(),
|
||||||
.join(Self::ADAPTER_PATH)
|
|
||||||
.to_string_lossy()
|
|
||||||
.to_string(),
|
|
||||||
port.to_string(),
|
port.to_string(),
|
||||||
host.to_string(),
|
host.to_string(),
|
||||||
]
|
]
|
||||||
|
|
|
@ -40,12 +40,7 @@ impl PythonDebugAdapter {
|
||||||
"Using user-installed debugpy adapter from: {}",
|
"Using user-installed debugpy adapter from: {}",
|
||||||
user_installed_path.display()
|
user_installed_path.display()
|
||||||
);
|
);
|
||||||
vec![
|
vec![user_installed_path.to_string_lossy().to_string()]
|
||||||
user_installed_path
|
|
||||||
.join(Self::ADAPTER_PATH)
|
|
||||||
.to_string_lossy()
|
|
||||||
.to_string(),
|
|
||||||
]
|
|
||||||
} else if installed_in_venv {
|
} else if installed_in_venv {
|
||||||
log::debug!("Using venv-installed debugpy");
|
log::debug!("Using venv-installed debugpy");
|
||||||
vec!["-m".to_string(), "debugpy.adapter".to_string()]
|
vec!["-m".to_string(), "debugpy.adapter".to_string()]
|
||||||
|
@ -700,7 +695,7 @@ mod tests {
|
||||||
let port = 5678;
|
let port = 5678;
|
||||||
|
|
||||||
// Case 1: User-defined debugpy path (highest precedence)
|
// Case 1: User-defined debugpy path (highest precedence)
|
||||||
let user_path = PathBuf::from("/custom/path/to/debugpy");
|
let user_path = PathBuf::from("/custom/path/to/debugpy/src/debugpy/adapter");
|
||||||
let user_args = PythonDebugAdapter::generate_debugpy_arguments(
|
let user_args = PythonDebugAdapter::generate_debugpy_arguments(
|
||||||
&host,
|
&host,
|
||||||
port,
|
port,
|
||||||
|
@ -717,7 +712,7 @@ mod tests {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert!(user_args[0].ends_with("src/debugpy/adapter"));
|
assert_eq!(user_args[0], "/custom/path/to/debugpy/src/debugpy/adapter");
|
||||||
assert_eq!(user_args[1], "--host=127.0.0.1");
|
assert_eq!(user_args[1], "--host=127.0.0.1");
|
||||||
assert_eq!(user_args[2], "--port=5678");
|
assert_eq!(user_args[2], "--port=5678");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue