diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index 2d4ae919f9..918e37fba9 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -371,6 +371,15 @@ impl WorkspaceDb { Ok(()) } + + query!{ + fn update_timestamp(workspace_id: WorkspaceId) -> Result<()> { + UPDATE workspaces + SET timestamp = CURRENT_TIMESTAMP + WHERE workspace_id = ? + } + } + } #[cfg(test)] diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 7dc8ddab06..43face78d8 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -172,7 +172,7 @@ pub fn init(app_state: Arc, cx: &mut MutableAppContext) { let app_state = Arc::downgrade(&app_state); move |_: &NewFile, cx: &mut MutableAppContext| { if let Some(app_state) = app_state.upgrade() { - open_new(&app_state, cx).detach(); + open_new(&app_state, false, cx).detach(); } } }); @@ -180,7 +180,7 @@ pub fn init(app_state: Arc, cx: &mut MutableAppContext) { let app_state = Arc::downgrade(&app_state); move |_: &NewWindow, cx: &mut MutableAppContext| { if let Some(app_state) = app_state.upgrade() { - open_new(&app_state, cx).detach(); + open_new(&app_state, true, cx).detach(); } } }); @@ -652,6 +652,7 @@ impl Workspace { fn new_local( abs_paths: Vec, app_state: Arc, + blank: bool, cx: &mut MutableAppContext, ) -> Task<( ViewHandle, @@ -666,7 +667,9 @@ impl Workspace { ); cx.spawn(|mut cx| async move { - let serialized_workspace = persistence::DB.workspace_for_roots(&abs_paths.as_slice()); + let serialized_workspace = (!blank) + .then(|| persistence::DB.workspace_for_roots(&abs_paths.as_slice())) + .flatten(); let paths_to_open = serialized_workspace .as_ref() @@ -804,7 +807,7 @@ impl Workspace { if self.project.read(cx).is_local() { Task::Ready(Some(callback(self, cx))) } else { - let task = Self::new_local(Vec::new(), app_state.clone(), cx); + let task = Self::new_local(Vec::new(), app_state.clone(), true, cx); cx.spawn(|_vh, mut cx| async move { let (workspace, _) = task.await; workspace.update(&mut cx, callback) @@ -2652,7 +2655,7 @@ pub fn open_paths( .contains(&false); cx.update(|cx| { - let task = Workspace::new_local(abs_paths, app_state.clone(), cx); + let task = Workspace::new_local(abs_paths, app_state.clone(), false, cx); cx.spawn(|mut cx| async move { let (workspace, items) = task.await; @@ -2671,8 +2674,8 @@ pub fn open_paths( }) } -pub fn open_new(app_state: &Arc, cx: &mut MutableAppContext) -> Task<()> { - let task = Workspace::new_local(Vec::new(), app_state.clone(), cx); +pub fn open_new(app_state: &Arc, blank: bool, cx: &mut MutableAppContext) -> Task<()> { + let task = Workspace::new_local(Vec::new(), app_state.clone(), blank, cx); cx.spawn(|mut cx| async move { let (workspace, opened_paths) = task.await; diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 9a827da8b7..67ac4e8f2b 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -765,7 +765,7 @@ mod tests { #[gpui::test] async fn test_new_empty_workspace(cx: &mut TestAppContext) { let app_state = init(cx); - cx.update(|cx| open_new(&app_state, cx)).await; + cx.update(|cx| open_new(&app_state, true, cx)).await; let window_id = *cx.window_ids().first().unwrap(); let workspace = cx.root_view::(window_id).unwrap();