windows: Fix extensions couldn't start if the path contained spaces (#15489)
Closes #15441 . Fixed the issue where extensions couldn't start if the path contained spaces. Additionally, this PR introduces the `node_environment_path` function to obtain the PATH environment variable which includes the node path. Release Notes: - N/A
This commit is contained in:
parent
e8dfc30314
commit
462808e5b0
2 changed files with 30 additions and 27 deletions
|
@ -23,10 +23,16 @@ const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server.ps1";
|
|||
#[cfg(not(target_os = "windows"))]
|
||||
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server";
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
||||
vec![server_path.into(), "--stdio".into()]
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
||||
vec!["-File".into(), server_path.into(), "--stdio".into()]
|
||||
}
|
||||
|
||||
pub struct TailwindLspAdapter {
|
||||
node: Arc<dyn NodeRuntime>,
|
||||
}
|
||||
|
@ -113,20 +119,7 @@ impl LspAdapter for TailwindLspAdapter {
|
|||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let mut env_path = vec![self
|
||||
.node
|
||||
.binary_path()
|
||||
.await?
|
||||
.parent()
|
||||
.expect("invalid node binary path")
|
||||
.to_path_buf()];
|
||||
|
||||
if let Some(existing_path) = std::env::var_os("PATH") {
|
||||
let mut paths = std::env::split_paths(&existing_path).collect::<Vec<_>>();
|
||||
env_path.append(&mut paths);
|
||||
}
|
||||
|
||||
let env_path = std::env::join_paths(env_path)?;
|
||||
let env_path = self.node.node_environment_path().await?;
|
||||
let mut env = HashMap::default();
|
||||
env.insert("PATH".to_string(), env_path.to_string_lossy().to_string());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue