Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix project panel being toggled on workspace startup. (#4059)

Piotr Osiewicz9a70a8947713
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index a7b9ad2404d..4301b6e392d 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -58,6 +58,7 @@ pub struct ProjectPanel {
workspace: WeakView<Workspace>,
width: Option<Pixels>,
pending_serialization: Task<Option<()>>,
+ was_deserialized: bool,
}
#[derive(Copy, Clone, Debug)]
@@ -243,6 +244,7 @@ impl ProjectPanel {
workspace: workspace.weak_handle(),
width: None,
pending_serialization: Task::ready(None),
+ was_deserialized: false,
};
this.update_visible_entries(None, cx);
@@ -322,6 +324,7 @@ impl ProjectPanel {
if let Some(serialized_panel) = serialized_panel {
panel.update(cx, |panel, cx| {
panel.width = serialized_panel.width;
+ panel.was_deserialized = true;
cx.notify();
});
}
@@ -1465,6 +1468,9 @@ impl ProjectPanel {
cx.notify();
}
}
+ pub fn was_deserialized(&self) -> bool {
+ self.was_deserialized
+ }
}
impl Render for ProjectPanel {
diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs
index d7686c425ad..bbe5e781094 100644
--- a/crates/zed/src/zed.rs
+++ b/crates/zed/src/zed.rs
@@ -178,7 +178,10 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
)?;
workspace_handle.update(&mut cx, |workspace, cx| {
- let position = project_panel.read(cx).position(cx);
+ let (position, was_deserialized) = {
+ let project_panel = project_panel.read(cx);
+ (project_panel.position(cx), project_panel.was_deserialized())
+ };
workspace.add_panel(project_panel, cx);
workspace.add_panel(terminal_panel, cx);
workspace.add_panel(assistant_panel, cx);
@@ -186,15 +189,16 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
workspace.add_panel(chat_panel, cx);
workspace.add_panel(notification_panel, cx);
- if workspace
- .project()
- .read(cx)
- .visible_worktrees(cx)
- .any(|tree| {
- tree.read(cx)
- .root_entry()
- .map_or(false, |entry| entry.is_dir())
- })
+ if !was_deserialized
+ && workspace
+ .project()
+ .read(cx)
+ .visible_worktrees(cx)
+ .any(|tree| {
+ tree.read(cx)
+ .root_entry()
+ .map_or(false, |entry| entry.is_dir())
+ })
{
workspace.toggle_dock(position, cx);
}