language: Make TreeSitterData only shared between snapshots of the same version (#44198)

Currently we have a single cache for this data shared between all
snapshots which is incorrect, as we might update the cache to a new
version while having old snapshots around which then may try to access
new data with old offsets/rows.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-12-12 14:15:50 +01:00
committed by GitHub
parent 610cc1b138
commit 18d344e118
4 changed files with 149 additions and 147 deletions
+7 -2
View File
@@ -2321,8 +2321,13 @@ impl BufferSnapshot {
} else if anchor.is_max() {
self.visible_text.len()
} else {
debug_assert!(anchor.buffer_id == Some(self.remote_id));
debug_assert!(self.version.observed(anchor.timestamp));
debug_assert_eq!(anchor.buffer_id, Some(self.remote_id));
debug_assert!(
self.version.observed(anchor.timestamp),
"Anchor timestamp {:?} not observed by buffer {:?}",
anchor.timestamp,
self.version
);
let anchor_key = InsertionFragmentKey {
timestamp: anchor.timestamp,
split_offset: anchor.offset,