diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-05-29 01:26:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 01:26:43 +0100 |
commit | 14a74600de6f1c206ffe4750f6cb6da59657db8e (patch) | |
tree | ce593041af972fd31f83fa6b7b50458bc9f689dc /cli/lsp/mod.rs | |
parent | 2024c974b613f94f31559a1b32e2d747c2083e91 (diff) |
perf(lsp): lock out requests until init is complete (#23998)
Diffstat (limited to 'cli/lsp/mod.rs')
-rw-r--r-- | cli/lsp/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cli/lsp/mod.rs b/cli/lsp/mod.rs index 07d829d91..79aa4d8f0 100644 --- a/cli/lsp/mod.rs +++ b/cli/lsp/mod.rs @@ -2,11 +2,11 @@ use deno_core::error::AnyError; use deno_core::unsync::spawn; -use tokio_util::sync::CancellationToken; use tower_lsp::LspService; use tower_lsp::Server; use crate::lsp::language_server::LanguageServer; +use crate::util::sync::AsyncFlag; pub use repl::ReplCompletionItem; pub use repl::ReplLanguageServer; @@ -44,11 +44,11 @@ pub async fn start() -> Result<(), AnyError> { let stdin = tokio::io::stdin(); let stdout = tokio::io::stdout(); - let token = CancellationToken::new(); + let shutdown_flag = AsyncFlag::default(); let builder = LspService::build(|client| { language_server::LanguageServer::new( client::Client::from_tower(client), - token.clone(), + shutdown_flag.clone(), ) }) .custom_method( @@ -80,7 +80,7 @@ pub async fn start() -> Result<(), AnyError> { let (service, socket) = builder.finish(); - // TODO(nayeemrmn): This cancellation token is a workaround for + // TODO(nayeemrmn): This shutdown flag is a workaround for // https://github.com/denoland/deno/issues/20700. Remove when // https://github.com/ebkalderon/tower-lsp/issues/399 is fixed. // Force end the server 8 seconds after receiving a shutdown request. @@ -88,7 +88,7 @@ pub async fn start() -> Result<(), AnyError> { biased; _ = Server::new(stdin, stdout, socket).serve(service) => {} _ = spawn(async move { - token.cancelled().await; + shutdown_flag.wait_raised().await; tokio::time::sleep(std::time::Duration::from_secs(8)).await; }) => {} } |