From d54dbe9d5f3e9e3042189565d6ed120e4900e68f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 20 Feb 2026 10:04:23 +0100 Subject: [PATCH] editor: Fix panic in minimap selection rendering (#49692) Fixes ZED-50Z Release Notes: - Fixed a crash when using the editor minimal --- crates/editor/src/element.rs | 38 +++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 0cdd1c80454b0154d719c636ee1f76411870eead..d76fb175c32188439dea8d392248cf70793fd1c2 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -9752,11 +9752,39 @@ impl Element for EditorElement { let mut highlighted_ranges = self .editor_with_selections(cx) .map(|editor| { - editor.read(cx).background_highlights_in_range( - start_anchor..end_anchor, - &snapshot.display_snapshot, - cx.theme(), - ) + if editor == self.editor { + editor.read(cx).background_highlights_in_range( + start_anchor..end_anchor, + &snapshot.display_snapshot, + cx.theme(), + ) + } else { + editor.update(cx, |editor, cx| { + let snapshot = editor.snapshot(window, cx); + let start_anchor = if start_row == Default::default() { + Anchor::min() + } else { + snapshot.buffer_snapshot().anchor_before( + DisplayPoint::new(start_row, 0) + .to_offset(&snapshot, Bias::Left), + ) + }; + let end_anchor = if end_row > max_row { + Anchor::max() + } else { + snapshot.buffer_snapshot().anchor_before( + DisplayPoint::new(end_row, 0) + .to_offset(&snapshot, Bias::Right), + ) + }; + + editor.background_highlights_in_range( + start_anchor..end_anchor, + &snapshot.display_snapshot, + cx.theme(), + ) + }) + } }) .unwrap_or_default();