From b575bc9a9d5d11dcc7391512843b795c192c65ac Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 22:43:13 -0500 Subject: [PATCH] Fix panic in commit editor selections syncing (cherry-pick #26186) (#26188) Cherry-picked Fix panic in commit editor selections syncing (#26186) Closes #26183 Release Notes: - Git Beta: Fixed a panic when selecting text in one of the commit message editors Co-authored-by: Cole Miller --- crates/editor/src/editor.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index d0ca38a1d433d7a017dda88c8c5dd75f6610bbdf..0b7d902e9c645ad6b4c2858a169deba06d1b6071 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2247,6 +2247,9 @@ impl Editor { cx.subscribe(&other, |this, other, other_evt, cx| match other_evt { EditorEvent::SelectionsChanged { local: true } => { let other_selections = other.read(cx).selections.disjoint.to_vec(); + if other_selections.is_empty() { + return; + } this.selections.change_with(cx, |selections| { selections.select_anchors(other_selections); }); @@ -2258,6 +2261,9 @@ impl Editor { cx.subscribe_self::(move |this, this_evt, cx| match this_evt { EditorEvent::SelectionsChanged { local: true } => { let these_selections = this.selections.disjoint.to_vec(); + if these_selections.is_empty() { + return; + } other.update(cx, |other_editor, cx| { other_editor.selections.change_with(cx, |selections| { selections.select_anchors(these_selections);