Unnamed repository; edit this file 'description' to name the repository.
fix(lsp): using :lsp-restart might silently fail (#15471)
Pavel 4 weeks ago
parent b910a59 · commit e1032d1
-rw-r--r--helix-lsp/src/transport.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/helix-lsp/src/transport.rs b/helix-lsp/src/transport.rs
index fa4966c4..2627d69d 100644
--- a/helix-lsp/src/transport.rs
+++ b/helix-lsp/src/transport.rs
@@ -345,6 +345,11 @@ impl Transport {
let mut pending_messages: Vec<Payload> = Vec::new();
let mut is_pending = true;
+ // Pin outside the loop to avoid cancellation-safety issue:
+ // recreating `notified()` inside `select!` can lose the permit.
+ let notified = initialize_notify.notified();
+ tokio::pin!(notified);
+
// Determine if a message is allowed to be sent early
fn is_initialize(payload: &Payload) -> bool {
use lsp::{
@@ -375,7 +380,7 @@ impl Transport {
loop {
tokio::select! {
biased;
- _ = initialize_notify.notified() => { // TODO: notified is technically not cancellation safe
+ _ = &mut notified, if is_pending => {
// server successfully initialized
is_pending = false;