mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
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:
commit
2d7cfb8c7c
@ -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
|
||||
}
|
||||
|
@ -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>,
|
||||
|
Loading…
Reference in New Issue
Block a user