From cc85a48de59cfcf6ef89c83caffdfe7e15f86a1c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 28 Sep 2025 13:01:16 +0200 Subject: [PATCH] editor: Fix panic when syncing empty selections (#39047) Fixes ZED-1KF Release Notes: - Fixed commit modal panicking in specific scenario --- crates/editor/src/editor.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index d2673a1d05cca3704034a75f9baf0eee114f4b99..0deb15e6b700abd44a065334c361ebbe3d05a4c9 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3293,9 +3293,11 @@ impl Editor { cx: &mut Context, ) -> gpui::Subscription { let other_selections = other.read(cx).selections.disjoint_anchors().to_vec(); - self.selections.change_with(cx, |selections| { - selections.select_anchors(other_selections); - }); + if !other_selections.is_empty() { + self.selections.change_with(cx, |selections| { + selections.select_anchors(other_selections); + }); + } let other_subscription = cx.subscribe(&other, |this, other, other_evt, cx| { if let EditorEvent::SelectionsChanged { local: true } = other_evt {