Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
workspace: Fix edge case when saving workspace with no paths (#52810)
Eric Huber85084b83878d
diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rsindex 7248abe9b8d..488cdcce506 100644--- a/crates/workspace/src/persistence.rs+++ b/crates/workspace/src/persistence.rs@@ -1529,6 +1529,21 @@ impl WorkspaceDb {.context("clearing out old locations")?;}+ // If there are no paths in the workspace, make sure to save+ // paths as NULL in the database, not as an empty string.+ // Otherwise, the workspace may fail to restore, potentially+ // losing any unsaved buffers.+ let maybe_paths = if !paths.paths.is_empty() {+ Some(paths.paths.clone())+ } else {+ None+ };+ let maybe_order = if !paths.order.is_empty() {+ Some(paths.order.clone())+ } else {+ None+ };+// Upsertlet query = sql!(INSERT INTO workspaces(@@ -1571,8 +1586,8 @@ impl WorkspaceDb {let mut prepared_query = conn.exec_bound(query)?;let args = (workspace.id,- paths.paths.clone(),- paths.order.clone(),+ maybe_paths,+ maybe_order,remote_connection_id,workspace.docks,workspace.session_id,