Avoid cloning configured env vars when starting a language server

The clone of the hashmap can be avoided by passing a ref instead. This
commit also changes the `server_environment` type to match the bounds
expected by `Command::envs` - this will avoid future refactoring if the
underlying type changes (for example switching to `hashbrown::HashMap`).
This commit is contained in:
Michael Davis 2025-02-19 10:16:45 -05:00
parent e0da129727
commit d031260180
No known key found for this signature in database
2 changed files with 9 additions and 6 deletions

View file

@ -16,11 +16,14 @@ use helix_stdx::path;
use parking_lot::Mutex;
use serde::Deserialize;
use serde_json::Value;
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
};
use std::{collections::HashMap, path::PathBuf};
use std::{
ffi::OsStr,
sync::{
atomic::{AtomicU64, Ordering},
Arc,
},
};
use std::{future::Future, sync::OnceLock};
use std::{path::Path, process::Stdio};
use tokio::{
@ -178,7 +181,7 @@ impl Client {
cmd: &str,
args: &[String],
config: Option<Value>,
server_environment: HashMap<String, String>,
server_environment: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>,
root_path: PathBuf,
root_uri: Option<lsp::Url>,
id: LanguageServerId,

View file

@ -871,7 +871,7 @@ fn start_client(
&ls_config.command,
&ls_config.args,
ls_config.config.clone(),
ls_config.environment.clone(),
&ls_config.environment,
root_path,
root_uri,
id,