From c41b25cc90a25537359079fcbb5271c4b34ca2f1 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Thu, 9 Jan 2025 17:35:19 -0700 Subject: [PATCH] Log an error when there are no buffer snapshots for some LSP version (#22934) I'm hoping this will bring more visibility to issues related to keeping track of what version of code the LSP has: * I've seen diagnostic ranges not appearing in the correct places. * There have also been reports of edits from language servers misapplying. This might bring more visibility to the issue - it doesn't seem good to silently use the current version of the buffer. Release Notes: - N/A --- crates/project/src/lsp_store.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index a04388d910..d5aa539ee8 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -2006,6 +2006,10 @@ impl LocalLspStore { snapshots.retain(|snapshot| snapshot.version + OLD_VERSIONS_TO_RETAIN >= version); Ok(found_snapshot) } else { + match buffer.read(cx).project_path(cx) { + Some(project_path) => log::error!("No LSP snapshots found for buffer with path {:?}", project_path.path), + None => log::error!("No LSP snapshots found for buffer without a project path (which is also unexpected)"), + } Ok((buffer.read(cx)).text_snapshot()) } }