From b6972d70a5f282fa13d6353d835a2ab680706c32 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Thu, 13 Nov 2025 21:18:05 +0530 Subject: [PATCH] editor: Fix panic when calculating jump data for buffer header (#42639) Just on nightly. Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored-by: Lukas Wirth --- crates/editor/src/element.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 16f8ef4fca612528467612c4d12fe3bc659d8e04..785fd9de00888a7f658785e689df34bd2cffdf8d 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -7799,18 +7799,21 @@ fn file_status_label_color(file_status: Option) -> Color { } fn header_jump_data( - snapshot: &EditorSnapshot, + editor_snapshot: &EditorSnapshot, block_row_start: DisplayRow, height: u32, first_excerpt: &ExcerptInfo, latest_selection_anchors: &HashMap, ) -> JumpData { let jump_target = if let Some(anchor) = latest_selection_anchors.get(&first_excerpt.buffer_id) - && let Some(range) = snapshot.context_range_for_excerpt(anchor.excerpt_id) + && let Some(range) = editor_snapshot.context_range_for_excerpt(anchor.excerpt_id) + && let Some(buffer) = editor_snapshot + .buffer_snapshot() + .buffer_for_excerpt(anchor.excerpt_id) { JumpTargetInExcerptInput { id: anchor.excerpt_id, - buffer: &first_excerpt.buffer, + buffer, excerpt_start_anchor: range.start, jump_anchor: anchor.text_anchor, } @@ -7822,7 +7825,7 @@ fn header_jump_data( jump_anchor: first_excerpt.range.primary.start, } }; - header_jump_data_inner(snapshot, block_row_start, height, &jump_target) + header_jump_data_inner(editor_snapshot, block_row_start, height, &jump_target) } struct JumpTargetInExcerptInput<'a> {