[WIP] editor: Implement next/prev reference (#41078)

Co-authored-by: Cole <cole@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Cameron Mcloughlin
2025-10-28 20:41:44 +00:00
committed by GitHub
co-authored by Cole Conrad Irwin
parent b75736568b
commit 5e7927f628
7 changed files with 313 additions and 0 deletions
+18
View File
@@ -1541,6 +1541,24 @@ impl MultiBuffer {
})
}
pub fn buffer_anchor_to_anchor(
&self,
buffer: &Entity<Buffer>,
anchor: text::Anchor,
cx: &App,
) -> Option<Anchor> {
let snapshot = buffer.read(cx).snapshot();
for (excerpt_id, range) in self.excerpts_for_buffer(snapshot.remote_id(), cx) {
if range.context.start.cmp(&anchor, &snapshot).is_le()
&& range.context.end.cmp(&anchor, &snapshot).is_ge()
{
return Some(Anchor::in_buffer(excerpt_id, snapshot.remote_id(), anchor));
}
}
None
}
pub fn remove_excerpts(
&mut self,
excerpt_ids: impl IntoIterator<Item = ExcerptId>,