diff options
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r-- | cli/lsp/language_server.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 9b3359db9..f8adb6bb6 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -30,6 +30,7 @@ use std::env; use std::fmt::Write as _; use std::path::PathBuf; use std::sync::Arc; +use tokio_util::sync::CancellationToken; use tower_lsp::jsonrpc::Error as LspError; use tower_lsp::jsonrpc::Result as LspResult; use tower_lsp::lsp_types::request::*; @@ -156,7 +157,7 @@ impl LspNpmConfigHash { } #[derive(Debug, Clone)] -pub struct LanguageServer(Arc<tokio::sync::RwLock<Inner>>); +pub struct LanguageServer(Arc<tokio::sync::RwLock<Inner>>, CancellationToken); #[derive(Debug)] pub struct StateNpmSnapshot { @@ -226,8 +227,11 @@ pub struct Inner { } impl LanguageServer { - pub fn new(client: Client) -> Self { - Self(Arc::new(tokio::sync::RwLock::new(Inner::new(client)))) + pub fn new(client: Client, token: CancellationToken) -> Self { + Self( + Arc::new(tokio::sync::RwLock::new(Inner::new(client))), + token, + ) } /// Similar to `deno cache` on the command line, where modules will be cached @@ -3216,6 +3220,7 @@ impl tower_lsp::LanguageServer for LanguageServer { } async fn shutdown(&self) -> LspResult<()> { + self.1.cancel(); self.0.write().await.shutdown().await } |