Fix focus bug with new docks

co-authored-by: max <max@zed.dev>
This commit is contained in:
Mikayla Maki 2023-05-30 15:40:30 -07:00
parent 5e4a9abd09
commit e80ab5f096
No known key found for this signature in database
2 changed files with 5 additions and 16 deletions

View file

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

View file

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