Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Emit `Focus` events from `Pane` only when it didn't have focus before
Antonio Scandurra5768f14a0388
diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rsindex 38e0706fb18..8c98ad8df70 100644--- a/crates/workspace2/src/pane.rs+++ b/crates/workspace2/src/pane.rs@@ -159,6 +159,7 @@ pub struct Pane {items: Vec<Box<dyn ItemHandle>>,activation_history: Vec<EntityId>,zoomed: bool,+ was_focused: bool,active_item_index: usize,last_focused_view_by_item: HashMap<EntityId, FocusHandle>,autoscroll: bool,@@ -317,6 +318,7 @@ impl Pane {focus_handle: cx.focus_handle(),items: Vec::new(),activation_history: Vec::new(),+ was_focused: false,zoomed: false,active_item_index: 0,last_focused_view_by_item: Default::default(),@@ -413,7 +415,8 @@ impl Pane {}fn focus_in(&mut self, cx: &mut ViewContext<Self>) {- if !self.has_focus(cx) {+ if !self.was_focused {+ self.was_focused = true;cx.emit(Event::Focus);cx.notify();}@@ -444,6 +447,7 @@ impl Pane {}fn focus_out(&mut self, cx: &mut ViewContext<Self>) {+ self.was_focused = false;self.toolbar.update(cx, |toolbar, cx| {toolbar.focus_changed(false, cx);});