Merge pull request #2454 from zed-industries/fix-mismatching-panes-when-deserializing-empty-panes

Fully remove panes and update internal data structures
This commit is contained in:
Mikayla Maki 2023-05-08 20:37:06 -04:00 committed by GitHub
commit 2d7cfb8c7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -147,7 +147,7 @@ impl SerializedPaneGroup {
} else {
let pane = pane.upgrade(cx)?;
workspace
.update(cx, |workspace, cx| workspace.remove_pane(pane, cx))
.update(cx, |workspace, cx| workspace.force_remove_pane(&pane, cx))
.log_err()?;
None
}

View File

@ -1743,16 +1743,12 @@ impl Workspace {
fn remove_pane(&mut self, pane: ViewHandle<Pane>, cx: &mut ViewContext<Self>) {
if self.center.remove(&pane).unwrap() {
self.panes.retain(|p| p != &pane);
cx.focus(self.panes.last().unwrap());
self.force_remove_pane(&pane, cx);
self.unfollow(&pane, cx);
self.last_leaders_by_pane.remove(&pane.downgrade());
for removed_item in pane.read(cx).items() {
self.panes_by_item.remove(&removed_item.id());
}
if self.last_active_center_pane == Some(pane.downgrade()) {
self.last_active_center_pane = None;
}
cx.notify();
} else {
@ -2459,10 +2455,21 @@ impl Workspace {
self.remove_panes(child.clone(), cx)
}
}
Member::Pane(pane) => self.remove_pane(pane.clone(), cx),
Member::Pane(pane) => {
self.force_remove_pane(&pane, cx);
}
}
}
fn force_remove_pane(&mut self, pane: &ViewHandle<Pane>, cx: &mut ViewContext<Workspace>) {
self.panes.retain(|p| p != pane);
cx.focus(self.panes.last().unwrap());
if self.last_active_center_pane == Some(pane.downgrade()) {
self.last_active_center_pane = None;
}
cx.notify();
}
fn serialize_workspace(&self, cx: &AppContext) {
fn serialize_pane_handle(
pane_handle: &ViewHandle<Pane>,