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.

Optimize project panel subscriptions (#8846)

Andrew Lygind7b5c883fec6
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index a065ad4b806..481086a8bb6 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -166,13 +166,7 @@ impl ProjectPanel {
fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
let project = workspace.project().clone();
let project_panel = cx.new_view(|cx: &mut ViewContext<Self>| {
- cx.observe(&project, |this, _, cx| {
- this.update_visible_entries(None, cx);
- cx.notify();
- })
- .detach();
let focus_handle = cx.focus_handle();
-
cx.on_focus(&focus_handle, Self::focus_in).detach();
cx.subscribe(&project, |this, project, event, cx| match event {
@@ -193,6 +187,10 @@ impl ProjectPanel {
this.update_visible_entries(None, cx);
cx.notify();
}
+ project::Event::WorktreeUpdatedEntries(_, _) | project::Event::WorktreeAdded => {
+ this.update_visible_entries(None, cx);
+ cx.notify();
+ }
_ => {}
})
.detach();