editor: Fix panic when syncing empty selections (#39047)

Fixes ZED-1KF

Release Notes:

- Fixed commit modal panicking in specific scenario
This commit is contained in:
Lukas Wirth
2025-09-28 13:01:16 +02:00
committed by GitHub
parent 4cd839e352
commit cc85a48de5

View File

@@ -3293,9 +3293,11 @@ impl Editor {
cx: &mut Context<Self>,
) -> 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 {