multi_buffer: Remap excerpt ids to latest excerpt in excerpt fetching (#44229)

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Co-authored by: Cole Miller <cole@zed.dev>
This commit is contained in:
Lukas Wirth
2025-12-05 18:20:29 +00:00
committed by GitHub
parent d76dd86272
commit 37b0cdf94b
3 changed files with 16 additions and 7 deletions
+3 -2
View File
@@ -6457,12 +6457,13 @@ impl MultiBufferSnapshot {
}
/// Returns the excerpt for the given id. The returned excerpt is guaranteed
/// to have the same excerpt id as the one passed in, with the exception of
/// `ExcerptId::max()`.
/// to have the latest excerpt id for the one passed in and will also remap
/// `ExcerptId::max()` to the corresponding excertp ID.
///
/// Callers of this function should generally use the resulting excerpt's `id` field
/// afterwards.
fn excerpt(&self, excerpt_id: ExcerptId) -> Option<&Excerpt> {
let excerpt_id = self.latest_excerpt_id(excerpt_id);
let mut cursor = self.excerpts.cursor::<Option<&Locator>>(());
let locator = self.excerpt_locator_for_id(excerpt_id);
cursor.seek(&Some(locator), Bias::Left);