Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
lsp: Fix buffer snapshots sometimes going missing (#25548)
Piotr Osiewicz86283f4e3d9d
diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rsindex 0c89f5c0f1a..6fbae51fc35 100644--- a/crates/project/src/lsp_store.rs+++ b/crates/project/src/lsp_store.rs@@ -1921,20 +1921,20 @@ impl LocalLspStore {version: 0,snapshot: initial_snapshot.clone(),};- let previous_snapshots = self- .buffer_snapshots+ self.buffer_snapshots.entry(buffer_id).or_default()- .insert(server.server_id(), vec![snapshot]);+ .entry(server.server_id())+ .or_insert_with(|| {+ server.register_buffer(+ uri.clone(),+ adapter.language_id(&language.name()),+ 0,+ initial_snapshot.text(),+ );- if previous_snapshots.is_none() {- server.register_buffer(- uri.clone(),- adapter.language_id(&language.name()),- 0,- initial_snapshot.text(),- );- }+ vec![snapshot]+ });}}}