Fix panel state (#13668)

In the latest update, panel loading occasionally occurred randomly,
either before or after workspace deserialization due to their
asynchronous nature. This update addresses the issue by ensuring panels
restore their state based on serialized data, synchronizing their
loading with workspace deserialization.

Release Notes:

- Fixed [#9638](https://github.com/zed-industries/zed/issues/9638)
- Fixed [#12954](https://github.com/zed-industries/zed/issues/12954)
This commit is contained in:
Yongkang Chen 2024-07-03 17:38:19 -07:00 committed by GitHub
parent 52583fe1ed
commit ed09bb949c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 27 deletions

View file

@ -3813,18 +3813,18 @@ impl Workspace {
let docks = serialized_workspace.docks;
let right = docks.right.clone();
workspace
.right_dock
.update(cx, |dock, _| dock.serialized_dock = Some(right));
let left = docks.left.clone();
workspace
.left_dock
.update(cx, |dock, _| dock.serialized_dock = Some(left));
let bottom = docks.bottom.clone();
workspace
.bottom_dock
.update(cx, |dock, _| dock.serialized_dock = Some(bottom));
for (dock, serialized_dock) in [
(&mut workspace.right_dock, docks.right),
(&mut workspace.left_dock, docks.left),
(&mut workspace.bottom_dock, docks.bottom),
]
.iter_mut()
{
dock.update(cx, |dock, cx| {
dock.serialized_dock = Some(serialized_dock.clone());
dock.restore_state(cx);
});
}
cx.notify();
})?;