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
This commit is contained in:
Michael Sloan 2025-01-09 17:35:19 -07:00 committed by GitHub
parent 685dd77d97
commit c41b25cc90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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())
}
}