workspace: Fix pane focus transfer when closing another pane (#23175)

Closes #23123 

Only close current active_pane should move focus to other pane.

Release Notes:

- N/A
This commit is contained in:
CharlesChen0823 2025-02-10 17:54:06 +08:00 committed by GitHub
parent 6f7f0f30e2
commit 994bea0003
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4442,10 +4442,12 @@ impl Workspace {
if let Some(focus_on) = focus_on {
focus_on.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx)));
} else {
self.panes
.last()
.unwrap()
.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx)));
if self.active_pane() == pane {
self.panes
.last()
.unwrap()
.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx)));
}
}
if self.last_active_center_pane == Some(pane.downgrade()) {
self.last_active_center_pane = None;