make thread safe connection more thread safe
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
9cd6894dc5
commit
a29ccb4ff8
12 changed files with 196 additions and 124 deletions
|
@ -162,11 +162,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
|||
let app_state = Arc::downgrade(&app_state);
|
||||
move |_: &NewFile, cx: &mut MutableAppContext| {
|
||||
if let Some(app_state) = app_state.upgrade() {
|
||||
let task = open_new(&app_state, cx);
|
||||
cx.spawn(|_| async {
|
||||
task.await;
|
||||
})
|
||||
.detach();
|
||||
open_new(&app_state, cx).detach();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -174,11 +170,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
|||
let app_state = Arc::downgrade(&app_state);
|
||||
move |_: &NewWindow, cx: &mut MutableAppContext| {
|
||||
if let Some(app_state) = app_state.upgrade() {
|
||||
let task = open_new(&app_state, cx);
|
||||
cx.spawn(|_| async {
|
||||
task.await;
|
||||
})
|
||||
.detach();
|
||||
open_new(&app_state, cx).detach();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2641,13 +2633,16 @@ pub fn open_paths(
|
|||
})
|
||||
}
|
||||
|
||||
fn open_new(app_state: &Arc<AppState>, cx: &mut MutableAppContext) -> Task<()> {
|
||||
pub fn open_new(app_state: &Arc<AppState>, cx: &mut MutableAppContext) -> Task<()> {
|
||||
let task = Workspace::new_local(Vec::new(), app_state.clone(), cx);
|
||||
cx.spawn(|mut cx| async move {
|
||||
eprintln!("Open new task spawned");
|
||||
let (workspace, opened_paths) = task.await;
|
||||
eprintln!("workspace and path items created");
|
||||
|
||||
workspace.update(&mut cx, |_, cx| {
|
||||
if opened_paths.is_empty() {
|
||||
eprintln!("new file redispatched");
|
||||
cx.dispatch_action(NewFile);
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue