acp_thread: Fix panic when following acp agents across buffers (#40798)

Fixes ZED-2D7

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-21 14:37:16 +00:00
committed by GitHub
parent 10b9ae5e44
commit 854d1ec4dc
2 changed files with 17 additions and 16 deletions
+8 -10
View File
@@ -6170,22 +6170,20 @@ impl MultiBufferSnapshot {
) -> SmallVec<[Locator; 1]> {
let mut sorted_ids = ids.into_iter().collect::<SmallVec<[_; 1]>>();
sorted_ids.sort_unstable();
sorted_ids.dedup();
let mut locators = SmallVec::new();
while sorted_ids.last() == Some(&ExcerptId::max()) {
sorted_ids.pop();
if let Some(mapping) = self.excerpt_ids.last() {
locators.push(mapping.locator.clone());
}
locators.push(Locator::max());
}
let mut sorted_ids = sorted_ids.into_iter().dedup().peekable();
if sorted_ids.peek() == Some(&ExcerptId::min()) {
sorted_ids.next();
if let Some(mapping) = self.excerpt_ids.first() {
locators.push(mapping.locator.clone());
}
}
let mut sorted_ids = sorted_ids.into_iter().peekable();
locators.extend(
sorted_ids
.peeking_take_while(|excerpt| *excerpt == ExcerptId::min())
.map(|_| Locator::min()),
);
let mut cursor = self.excerpt_ids.cursor::<ExcerptId>(());
for id in sorted_ids {