Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge pull request #1972 from zed-industries/recent-workspace
Kay Simmons6fcb3c90200e
diff --cc crates/workspace/src/persistence.rsindex 9f957f6e18b,fcbdb1deba5..8e909583deb--- a/crates/workspace/src/persistence.rs+++ b/crates/workspace/src/persistence.rs@@@ -195,25 -201,38 +195,48 @@@ impl WorkspaceDbFROM workspacesWHERE workspace_location IS NOT NULLORDER BY timestamp DESC- LIMIT ?}}++ query! {+ async fn delete_stale_workspace(id: WorkspaceId) -> Result<()> {+ DELETE FROM workspaces+ WHERE workspace_id IS ?+ }+ }++ // Returns the recent locations which are still valid on disk and deletes ones which no longer+ // exist.+ pub async fn recent_workspaces_on_disk(&self) -> Result<Vec<(WorkspaceId, WorkspaceLocation)>> {+ let mut result = Vec::new();+ let mut delete_tasks = Vec::new();+ for (id, location) in self.recent_workspaces()? {+ if location.paths().iter().all(|path| dbg!(path).exists()) {+ result.push((id, location));+ } else {+ delete_tasks.push(self.delete_stale_workspace(id));+ }+ }++ futures::future::join_all(delete_tasks).await;+ Ok(result)+ }+ query! {+ pub fn last_workspace() -> Result<Option<WorkspaceLocation>> {+ SELECT workspace_location+ FROM workspaces+ WHERE workspace_location IS NOT NULL+ ORDER BY timestamp DESC+ LIMIT 1+ }+ }+fn get_center_pane_group(&self, workspace_id: WorkspaceId) -> Result<SerializedPaneGroup> {- self.get_pane_group(workspace_id, None)?+ Ok(self.get_pane_group(workspace_id, None)?.into_iter().next()- .context("No center pane group")+ .unwrap_or_else(|| SerializedPaneGroup::Pane(SerializedPane { active: true, children: vec![] })))}fn get_pane_group(diff --cc crates/zed/src/main.rsindex bffd567505b,c06023086f3..5ac7cb36b6d--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@@ -121,8 -119,9 +121,9 @@@ fn main()diagnostics::init(cx);search::init(cx);vim::init(cx);- terminal::init(cx);+ terminal_view::init(cx);theme_testbench::init(cx);+ recent_projects::init(cx);cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx)).detach();