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
|
@ -395,7 +395,7 @@ mod tests {
|
|||
async fn test_next_id_stability() {
|
||||
env_logger::try_init().ok();
|
||||
|
||||
let db = WorkspaceDb(open_memory_db("test_next_id_stability"));
|
||||
let db = WorkspaceDb(open_memory_db("test_next_id_stability").await);
|
||||
|
||||
db.write(|conn| {
|
||||
conn.migrate(
|
||||
|
@ -442,7 +442,7 @@ mod tests {
|
|||
async fn test_workspace_id_stability() {
|
||||
env_logger::try_init().ok();
|
||||
|
||||
let db = WorkspaceDb(open_memory_db("test_workspace_id_stability"));
|
||||
let db = WorkspaceDb(open_memory_db("test_workspace_id_stability").await);
|
||||
|
||||
db.write(|conn| {
|
||||
conn.migrate(
|
||||
|
@ -523,7 +523,7 @@ mod tests {
|
|||
async fn test_full_workspace_serialization() {
|
||||
env_logger::try_init().ok();
|
||||
|
||||
let db = WorkspaceDb(open_memory_db("test_full_workspace_serialization"));
|
||||
let db = WorkspaceDb(open_memory_db("test_full_workspace_serialization").await);
|
||||
|
||||
let dock_pane = crate::persistence::model::SerializedPane {
|
||||
children: vec![
|
||||
|
@ -597,7 +597,7 @@ mod tests {
|
|||
async fn test_workspace_assignment() {
|
||||
env_logger::try_init().ok();
|
||||
|
||||
let db = WorkspaceDb(open_memory_db("test_basic_functionality"));
|
||||
let db = WorkspaceDb(open_memory_db("test_basic_functionality").await);
|
||||
|
||||
let workspace_1 = SerializedWorkspace {
|
||||
id: 1,
|
||||
|
@ -689,7 +689,7 @@ mod tests {
|
|||
async fn test_basic_dock_pane() {
|
||||
env_logger::try_init().ok();
|
||||
|
||||
let db = WorkspaceDb(open_memory_db("basic_dock_pane"));
|
||||
let db = WorkspaceDb(open_memory_db("basic_dock_pane").await);
|
||||
|
||||
let dock_pane = crate::persistence::model::SerializedPane::new(
|
||||
vec![
|
||||
|
@ -714,7 +714,7 @@ mod tests {
|
|||
async fn test_simple_split() {
|
||||
env_logger::try_init().ok();
|
||||
|
||||
let db = WorkspaceDb(open_memory_db("simple_split"));
|
||||
let db = WorkspaceDb(open_memory_db("simple_split").await);
|
||||
|
||||
// -----------------
|
||||
// | 1,2 | 5,6 |
|
||||
|
@ -766,7 +766,7 @@ mod tests {
|
|||
async fn test_cleanup_panes() {
|
||||
env_logger::try_init().ok();
|
||||
|
||||
let db = WorkspaceDb(open_memory_db("test_cleanup_panes"));
|
||||
let db = WorkspaceDb(open_memory_db("test_cleanup_panes").await);
|
||||
|
||||
let center_pane = SerializedPaneGroup::Group {
|
||||
axis: gpui::Axis::Horizontal,
|
||||
|
|
|
@ -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