Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Antonio Scandurra2e2825ae9830
diff --git a/crates/gpui2/src/app.rs b/crates/gpui2/src/app.rsindex d3118323abc..16e22f6cefd 100644--- a/crates/gpui2/src/app.rs+++ b/crates/gpui2/src/app.rs@@ -26,7 +26,6 @@ use std::{};use util::http::{self, HttpClient};-#[derive(Clone)]pub struct App(Arc<Mutex<AppContext>>);impl App {@@ -83,15 +82,49 @@ impl App {whereF: 'static + FnOnce(&mut MainThread<AppContext>),{- let this = self.clone();+ let this = self.0.clone();let platform = self.0.lock().platform.clone();platform.borrow_on_main_thread().run(Box::new(move || {- let cx = &mut *this.0.lock();+ let cx = &mut *this.lock();let cx = unsafe { mem::transmute::<&mut AppContext, &mut MainThread<AppContext>>(cx) };on_finish_launching(cx);}));}+ pub fn on_open_urls<F>(&self, mut callback: F) -> &Self+ where+ F: 'static + FnMut(Vec<String>, &mut AppContext),+ {+ let this = Arc::downgrade(&self.0);+ self.0+ .lock()+ .platform+ .borrow_on_main_thread()+ .on_open_urls(Box::new(move |urls| {+ if let Some(app) = this.upgrade() {+ callback(urls, &mut app.lock());+ }+ }));+ self+ }++ pub fn on_reopen<F>(&self, mut callback: F) -> &Self+ where+ F: 'static + FnMut(&mut AppContext),+ {+ let this = Arc::downgrade(&self.0);+ self.0+ .lock()+ .platform+ .borrow_on_main_thread()+ .on_reopen(Box::new(move || {+ if let Some(app) = this.upgrade() {+ callback(&mut app.lock());+ }+ }));+ self+ }+pub fn executor(&self) -> Executor {self.0.lock().executor.clone()}diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rsindex f30e4873ebb..ae829481204 100644--- a/crates/zed2/src/main.rs+++ b/crates/zed2/src/main.rs@@ -18,7 +18,6 @@ use settings2::{default_settings, handle_settings_file_changes, watch_config_filuse simplelog::ConfigBuilder;use smol::process::Command;use std::{- collections::HashMap,env,fs::OpenOptions,io::IsTerminal,@@ -78,15 +77,15 @@ fn main() {let callback_listener = listener.clone();app.on_open_urls(move |urls, _| callback_listener.open_urls(urls)).on_reopen(move |cx| {- if cx.has_global::<Weak<AppState>>() {- if let Some(app_state) = cx.global::<Weak<AppState>>().upgrade() {- // todo!("workspace")- // workspace::open_new(&app_state, cx, |workspace, cx| {- // Editor::new_file(workspace, &Default::default(), cx)- // })- // .detach();- }- }+ // todo!("workspace")+ // if cx.has_global::<Weak<AppState>>() {+ // if let Some(app_state) = cx.global::<Weak<AppState>>().upgrade() {+ // workspace::open_new(&app_state, cx, |workspace, cx| {+ // Editor::new_file(workspace, &Default::default(), cx)+ // })+ // .detach();+ // }+ // }});app.run(move |cx| {diff --git a/crates/zed2/src/zed2.rs b/crates/zed2/src/zed2.rsindex 00d5b9a7002..9fb379b48ca 100644--- a/crates/zed2/src/zed2.rs+++ b/crates/zed2/src/zed2.rs@@ -48,12 +48,12 @@ pub struct AppState;pub async fn handle_cli_connection((mut requests, responses): (mpsc::Receiver<CliRequest>, IpcSender<CliResponse>),- app_state: Arc<AppState>,- mut cx: AsyncAppContext,+ _app_state: Arc<AppState>,+ mut _cx: AsyncAppContext,) {if let Some(request) = requests.next().await {match request {- CliRequest::Open { paths, wait } => {+ CliRequest::Open { paths: _, wait: _ } => {// let mut caret_positions = HashMap::new();// let paths = if paths.is_empty() {