From ad8f41a7ce0d775156d359732e10405b678c6aec Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Thu, 22 Jan 2026 16:10:16 -0500 Subject: [PATCH] git: Fix double-lease panic when syncing selections in side-by-side diff (#47430) Release Notes: - N/A --- crates/editor/src/split.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rs index f8ff92b0e4cc25756b0e26a3afd437ce166524ff..13c6ee2f014eef197f92eec4f53003ec585dba93 100644 --- a/crates/editor/src/split.rs +++ b/crates/editor/src/split.rs @@ -545,13 +545,15 @@ impl SplittableEditor { let this = this.clone(); editor.set_on_local_selections_changed(Some(Box::new( move |cursor_position, window, cx| { - if let Some(this) = this.upgrade() { + let this = this.clone(); + window.defer(cx, move |window, cx| { this.update(cx, |this, cx| { if this.locked_cursors { this.sync_cursor_to_other_side(true, cursor_position, window, cx); } - }); - } + }) + .ok(); + }) }, ))); }); @@ -560,13 +562,15 @@ impl SplittableEditor { let this = this.clone(); editor.set_on_local_selections_changed(Some(Box::new( move |cursor_position, window, cx| { - if let Some(this) = this.upgrade() { + let this = this.clone(); + window.defer(cx, move |window, cx| { this.update(cx, |this, cx| { if this.locked_cursors { this.sync_cursor_to_other_side(false, cursor_position, window, cx); } - }); - } + }) + .ok(); + }) }, ))); });