Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

lsp: explicitly drop locks in handle_input (#12276)

Piotr Osiewicze5085dfef662
diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs
index 2d789b976bc..73a7129ba9a 100644
--- a/crates/lsp/src/lsp.rs
+++ b/crates/lsp/src/lsp.rs
@@ -452,24 +452,27 @@ impl LanguageServer {
}
if let Ok(msg) = serde_json::from_slice::<AnyNotification>(&buffer) {
- if let Some(handler) = notification_handlers.lock().get_mut(msg.method) {
+ let mut notification_handlers = notification_handlers.lock();
+ if let Some(handler) = notification_handlers.get_mut(msg.method) {
handler(
msg.id,
msg.params.map(|params| params.get()).unwrap_or("null"),
cx.clone(),
);
} else {
+ drop(notification_handlers);
on_unhandled_notification(msg);
}
} else if let Ok(AnyResponse {
id, error, result, ..
}) = serde_json::from_slice(&buffer)
{
+ let mut response_handlers = response_handlers.lock();
if let Some(handler) = response_handlers
- .lock()
.as_mut()
.and_then(|handlers| handlers.remove(&id))
{
+ drop(response_handlers);
if let Some(error) = error {
handler(Err(error));
} else if let Some(result) = result {