dap: Allow user to pass custom envs to adapter via project settings (#40490)

It is now possible to configure logging level of CodeLLDB adapter via
envs specified in project settings like so:

```
{
    "dap": {
        "CodeLLDB": {
            "envs": {
                "RUST_LOG": "debug"
            }
        }
    }
}
```

Release Notes:

- N/A
This commit is contained in:
Jakub Konka
2025-10-17 16:48:00 +00:00
committed by GitHub
parent c1e87c8a00
commit 73e028c01c
13 changed files with 62 additions and 19 deletions
+14 -4
View File
@@ -1,5 +1,6 @@
use crate::*;
use anyhow::{Context as _, bail};
use collections::HashMap;
use dap::{DebugRequest, StartDebuggingRequestArguments, adapters::DebugTaskDefinition};
use fs::RemoveOptions;
use futures::{StreamExt, TryStreamExt};
@@ -16,7 +17,6 @@ use std::ffi::OsString;
use std::net::Ipv4Addr;
use std::str::FromStr;
use std::{
collections::HashMap,
ffi::OsStr,
path::{Path, PathBuf},
};
@@ -312,6 +312,7 @@ impl PythonDebugAdapter {
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
user_args: Option<Vec<String>>,
user_env: Option<HashMap<String, String>>,
python_from_toolchain: Option<String>,
) -> Result<DebugAdapterBinary> {
let tcp_connection = config.tcp_connection.clone().unwrap_or_default();
@@ -349,7 +350,7 @@ impl PythonDebugAdapter {
timeout,
}),
cwd: Some(delegate.worktree_root_path().to_path_buf()),
envs: HashMap::default(),
envs: user_env.unwrap_or_default(),
request_args: self.request_args(delegate, config).await?,
})
}
@@ -744,6 +745,7 @@ impl DebugAdapter for PythonDebugAdapter {
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
user_args: Option<Vec<String>>,
user_env: Option<HashMap<String, String>>,
cx: &mut AsyncApp,
) -> Result<DebugAdapterBinary> {
if let Some(local_path) = &user_installed_path {
@@ -752,7 +754,14 @@ impl DebugAdapter for PythonDebugAdapter {
local_path.display()
);
return self
.get_installed_binary(delegate, config, Some(local_path.clone()), user_args, None)
.get_installed_binary(
delegate,
config,
Some(local_path.clone()),
user_args,
user_env,
None,
)
.await;
}
@@ -790,12 +799,13 @@ impl DebugAdapter for PythonDebugAdapter {
config,
None,
user_args,
user_env,
Some(toolchain.path.to_string()),
)
.await;
}
self.get_installed_binary(delegate, config, None, user_args, None)
self.get_installed_binary(delegate, config, None, user_args, user_env, None)
.await
}