Fix focus bug with new docks

Mikayla Maki and max created

co-authored-by: max <max@zed.dev>

Change summary

crates/workspace/src/pane.rs      | 15 ++++-----------
crates/workspace/src/workspace.rs |  6 +-----
2 files changed, 5 insertions(+), 16 deletions(-)

Detailed changes

crates/workspace/src/pane.rs 🔗

@@ -306,15 +306,6 @@ impl Pane {
         &self.workspace
     }
 
-    pub fn is_active(&self) -> bool {
-        self.is_active
-    }
-
-    pub fn set_active(&mut self, is_active: bool, cx: &mut ViewContext<Self>) {
-        self.is_active = is_active;
-        cx.notify();
-    }
-
     pub fn has_focus(&self) -> bool {
         self.has_focus
     }
@@ -1129,7 +1120,7 @@ impl Pane {
             None
         };
 
-        let pane_active = self.is_active;
+        let pane_active = self.has_focus;
 
         enum Tabs {}
         let mut row = Flex::row().scrollable::<Tabs>(1, autoscroll, cx);
@@ -1508,7 +1499,7 @@ impl View for Pane {
                         let mut tab_row = Flex::row()
                             .with_child(self.render_tabs(cx).flex(1., true).into_any_named("tabs"));
 
-                        if self.is_active {
+                        if self.has_focus {
                             let render_tab_bar_buttons = self.render_tab_bar_buttons.clone();
                             tab_row.add_child(
                                 (render_tab_bar_buttons)(self, cx)
@@ -1599,6 +1590,7 @@ impl View for Pane {
         if !self.has_focus {
             self.has_focus = true;
             cx.emit(Event::Focus);
+            cx.notify();
         }
 
         self.toolbar.update(cx, |toolbar, cx| {
@@ -1633,6 +1625,7 @@ impl View for Pane {
         self.toolbar.update(cx, |toolbar, cx| {
             toolbar.pane_focus_update(false, cx);
         });
+        cx.notify();
     }
 
     fn update_keymap_context(&self, keymap: &mut KeymapContext, _: &AppContext) {

crates/workspace/src/workspace.rs 🔗

@@ -1945,11 +1945,7 @@ impl Workspace {
 
     fn handle_pane_focused(&mut self, pane: ViewHandle<Pane>, cx: &mut ViewContext<Self>) {
         if self.active_pane != pane {
-            self.active_pane
-                .update(cx, |pane, cx| pane.set_active(false, cx));
             self.active_pane = pane.clone();
-            self.active_pane
-                .update(cx, |pane, cx| pane.set_active(true, cx));
             self.status_bar.update(cx, |status_bar, cx| {
                 status_bar.set_active_pane(&self.active_pane, cx);
             });
@@ -2868,7 +2864,7 @@ impl Workspace {
                             })
                         })
                         .collect::<Vec<_>>(),
-                    pane.is_active(),
+                    pane.has_focus(),
                 )
             };