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.

project_panel: Create items when the editor is dismissed via the mouse (#21045)

CharlesChen0823241b14eeafcf
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index 03a85f74f36..a02b2e20a85 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -281,6 +281,7 @@ impl ProjectPanel {
let focus_handle = cx.focus_handle();
cx.on_focus(&focus_handle, Self::focus_in).detach();
cx.on_focus_out(&focus_handle, |this, _, cx| {
+ this.focus_out(cx);
this.hide_scrollbar(cx);
})
.detach();
@@ -595,6 +596,12 @@ impl ProjectPanel {
}
}
+ fn focus_out(&mut self, cx: &mut ViewContext<Self>) {
+ if !self.focus_handle.is_focused(cx) {
+ self.confirm(&Confirm, cx);
+ }
+ }
+
fn deploy_context_menu(
&mut self,
position: Point<Pixels>,