Fix lang servers status set to Downloading when checking version (#22292)

This message has confused me many times too: we printed the status as
"Downloading" when we were only checking whether we need to install a
given version of a language server.

This fixes the issue for Node-based language servers where we had the
same check in all implementations.

Closes  #22241

Release Notes:

- Fixed some language servers reporting status as "Downloading..." when
only a version check was being done.
This commit is contained in:
Thorsten Ball 2024-12-20 17:59:10 +01:00 committed by GitHub
parent 8a858fee7c
commit d824baeece
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 235 additions and 92 deletions

View file

@ -117,24 +117,12 @@ impl LspAdapter for PythonLspAdapter {
let latest_version = latest_version.downcast::<String>().unwrap();
let server_path = container_dir.join(SERVER_PATH);
let should_install_language_server = self
.node
.should_install_npm_package(
Self::SERVER_NAME.as_ref(),
&server_path,
self.node
.npm_install_packages(
&container_dir,
&latest_version,
&[(Self::SERVER_NAME.as_ref(), latest_version.as_str())],
)
.await;
if should_install_language_server {
self.node
.npm_install_packages(
&container_dir,
&[(Self::SERVER_NAME.as_ref(), latest_version.as_str())],
)
.await?;
}
.await?;
Ok(LanguageServerBinary {
path: self.node.binary_path().await?,
@ -143,6 +131,36 @@ impl LspAdapter for PythonLspAdapter {
})
}
async fn check_if_version_installed(
&self,
version: &(dyn 'static + Send + Any),
container_dir: &PathBuf,
_: &dyn LspAdapterDelegate,
) -> Option<LanguageServerBinary> {
let version = version.downcast_ref::<String>().unwrap();
let server_path = container_dir.join(SERVER_PATH);
let should_install_language_server = self
.node
.should_install_npm_package(
Self::SERVER_NAME.as_ref(),
&server_path,
&container_dir,
&version,
)
.await;
if should_install_language_server {
None
} else {
Some(LanguageServerBinary {
path: self.node.binary_path().await.ok()?,
env: None,
arguments: server_binary_arguments(&server_path),
})
}
}
async fn cached_server_binary(
&self,
container_dir: PathBuf,