Fix path for vscode-html-language-server when found on PATH (#40832)

Don't prepend the worktree root when using an absolute path from
`Worktree::which`, since that does the wrong thing when running in
wasmtime given two Windows absolute paths. Also don't pass this path to
`node`, since when npm installed it's a sh/cmd wrapper not a JS file.

Part of #39153, also needs a fix on the vscode-langservers-extracted
side (missing shebang for the vscode-html-language-server script).

Release Notes:

- Fixed Zed failing to run the HTML language server in some cases.
This commit is contained in:
Cole Miller 2025-10-22 22:44:25 -04:00 committed by GitHub
parent f9e0642a72
commit bf63ff2b91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,22 +68,24 @@ impl zed::Extension for HtmlExtension {
worktree: &zed::Worktree,
) -> Result<zed::Command> {
let server_path = if let Some(path) = worktree.which(BINARY_NAME) {
path
return Ok(zed::Command {
command: path,
args: vec!["--stdio".to_string()],
env: Default::default(),
});
} else {
self.server_script_path(language_server_id)?
let server_path = self.server_script_path(language_server_id)?;
env::current_dir()
.unwrap()
.join(&server_path)
.to_string_lossy()
.to_string()
};
self.cached_binary_path = Some(server_path.clone());
Ok(zed::Command {
command: zed::node_binary_path()?,
args: vec![
env::current_dir()
.unwrap()
.join(&server_path)
.to_string_lossy()
.to_string(),
"--stdio".to_string(),
],
args: vec![server_path, "--stdio".to_string()],
env: Default::default(),
})
}