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
This commit is contained in:
parent
4c0750bd2f
commit
aec4d5cb26
1 changed files with 6 additions and 0 deletions
|
@ -2247,6 +2247,9 @@ impl Editor {
|
||||||
cx.subscribe(&other, |this, other, other_evt, cx| match other_evt {
|
cx.subscribe(&other, |this, other, other_evt, cx| match other_evt {
|
||||||
EditorEvent::SelectionsChanged { local: true } => {
|
EditorEvent::SelectionsChanged { local: true } => {
|
||||||
let other_selections = other.read(cx).selections.disjoint.to_vec();
|
let other_selections = other.read(cx).selections.disjoint.to_vec();
|
||||||
|
if other_selections.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.selections.change_with(cx, |selections| {
|
this.selections.change_with(cx, |selections| {
|
||||||
selections.select_anchors(other_selections);
|
selections.select_anchors(other_selections);
|
||||||
});
|
});
|
||||||
|
@ -2258,6 +2261,9 @@ impl Editor {
|
||||||
cx.subscribe_self::<EditorEvent>(move |this, this_evt, cx| match this_evt {
|
cx.subscribe_self::<EditorEvent>(move |this, this_evt, cx| match this_evt {
|
||||||
EditorEvent::SelectionsChanged { local: true } => {
|
EditorEvent::SelectionsChanged { local: true } => {
|
||||||
let these_selections = this.selections.disjoint.to_vec();
|
let these_selections = this.selections.disjoint.to_vec();
|
||||||
|
if these_selections.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
other.update(cx, |other_editor, cx| {
|
other.update(cx, |other_editor, cx| {
|
||||||
other_editor.selections.change_with(cx, |selections| {
|
other_editor.selections.change_with(cx, |selections| {
|
||||||
selections.select_anchors(these_selections);
|
selections.select_anchors(these_selections);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue