Wire up `NewFile` action

Marshall Bowers created

Change summary

crates/editor2/src/editor.rs | 11 +++++++++++
1 file changed, 11 insertions(+)

Detailed changes

crates/editor2/src/editor.rs 🔗

@@ -92,6 +92,7 @@ use std::{
     ops::{ControlFlow, Deref, DerefMut, Range, RangeInclusive},
     path::Path,
     sync::Arc,
+    sync::Weak,
     time::{Duration, Instant},
 };
 pub use sum_tree::Bias;
@@ -420,6 +421,16 @@ pub fn init(cx: &mut AppContext) {
         },
     )
     .detach();
+
+    cx.on_action(move |_: &workspace::NewFile, cx| {
+        let app_state = cx.global::<Weak<workspace::AppState>>();
+        if let Some(app_state) = app_state.upgrade() {
+            workspace::open_new(&app_state, cx, |workspace, cx| {
+                Editor::new_file(workspace, &Default::default(), cx)
+            })
+            .detach();
+        }
+    });
 }
 
 trait InvalidationRegion {